 Gary was elected to the state senate from Edgefield County in 1876, and he was reelected in 1878.During his time in the State Senate, he became a vocal opponent of Governor Hampton because Hampton blocked his appointment to a U.S. Senate seat in 1877 and 1879.In addition, Hampton and his allies prevented Gary's candidacy in the gubernatorial election of 1880.