"Article II, Section 1 of the Constitution explains that, if the Electoral College fails to elect a President, " the House of Representatives shall immediately choose by ballot one of [the candidates] for president." The House of Representatives has had to do this twice: in 1801 and 1825.".
In 1800 in the fourth election the Federalists nominated John Adams to be President and the Charles Pinckney to be Vice President. The Democratic-Republicans nominated Jefferson as President and Aaron Burr as Vice President. The Democratic-Republicans made the mistake of assigning the same number of electoral votes to both Jefferson as Burr. Thus no one had the majority of votes, and the election was turned over to the House of Representatives.
The election of 1824 was the second decided by the House of Representatives. The four major candidates were John Quincy Adams, Henry Clay, William H Crawford, and Andrew Jackson. When the electors were counted Jackson had 99, Adams 84, Crawford 41 and Clay 37. The election was thrown to the House of Representatives with the three leading candidates competing. Adams won on the first ballot of the House of Representatives.