Between an economic depression and corruption in the Grant administration, the Republican party was struggling.
Hayes ran against a popular New York governor, Samuel Tilden. As the election results came in, Florida, Louisiana, and South Carolina had no clear winner. Both candidates claimed to have won those states. A special election commission was assembled to determine the results of the election.
The commission awarded all three states to Hayes (possibly because of promises to remove remaining federal troops in the south). Hayes won the election by one electoral vote, even though Tilden had roughly 250,000 more popular votes.