The general consensus among historians is that there were quite a few irregularities in the vote, from which the Democratic candidate Samuel J. Tilden was the main beneficiary. Republican voters in the South, especially newly-enfranchised blacks, were often subject to intimidation and threats of violence. Inevitably, this greatly reduced the overall Republican vote, leading to a number of highly skewed results in states such as South Carolina, Florida, and Louisiana.
Such blatant shenanigans led to a formal dispute over these states' electoral college votes, all of whom had originally been awarded to Tilden. In response to Republican outrage, and with Inauguration Day fast approaching, a special commission was appointed to decide what to do next. Controversially, the commission decided to award all the disputed Southern votes, as well as Oregon's electoral college votes, to Hayes. Thus Hayes was elected as the 19th President of the United States, despite losing the popular vote, and—initially—the electoral college vote as well.