In the Election of 1824, four candidates ran for president. Andrew Jackson, John Quincy Adams, William H. Crawford, and Henry Clay. All of which represented their geological regions. But the focus was on Jackson and Adams.
Jackson won 43% of the popular vote and 99 electoral votes (the most among the candidates). Adams came in second, 31% pop. vote and 83 electoral. However, since neither had a electoral majority, the presidential election was left up to the House Of Representatives.
Here, Clay threw his support for Adams and the House elected Adams as president. This act was legitimate. The Constitution gave the House the power to decide, and Clay had every right to advise his followers on how to vote.
So, although Jackson led Adams in both popular vote and electoral votes, the House still elected Adams as president of the United States.