 Shafer was first elected to the state senate in a nonpartisan special election on February 12, 2002, defeating three other candidates in a race to succeed Senator Billy Ray, who had resigned from the Senate to accept a judicial appointment to the Superior Court.Shafer caucused with the Republican Party.Shafer was re-elected in the 2002, 2004, 2006, 2008, 2010, 2012, 2014 and 2016 general elections as a Republican.