After the war, he served in Congress from 1865 to 1867 as a Republican. Hayes left Congress to run for governor of Ohio and was elected to two consecutive terms, from 1868 to 1872. Later he served a third two-year term, from 1876 to 1877. Later he served a third two-year term, from 1876 to 1877. In 1876 the Electoral College made Hayes president in one of the most contentious elections in U.S. history. He lost the popular vote to Democrat Samuel J. Tilden, but won an intensely disputed electoral-college vote after a Congressional commission awarded him 20 contested electoral votes.