Barnes was the Republican nominee for attorney general in 1938 but lost to incumbent Paul A. Dever. He ran again in 1940, but lost the Republican nomination to Robert T. Bushnell. Barnes was a member of the Massachusetts Governor's Council from 1943 to 1944. In 1944, he defeated former Lieutenant Governor Francis E. Kelly to become attorney general. Barnes defeated Kelly again in 1946, but lost to him in 1948. He was a candidate for governor in 1950, but lost the nomination to Arthur W. Coolidge. Barnes was also a delegate to the Republican National Convention in 1940, 1944, 1948, and 1952.