This was the famous "Corrupt Bargain" election.
The final result was decided by the House of Representatives. They voted for John Adams over either Henry Clay or Andrew Jackson.
The reason that the House of Representatives decided the election is that the Constitution says that the House must do so in any case where no candidate gets more than half of the electoral votes. The three candidates split in a way that none got a majority, but Jackson got the most votes.
Clay and Adams were believed to have made a deal where Clay's supporters would vote for Adams and Adams would make Clay the Secretary of State. That is why it is called the "Corrupt Bargain."
Politics continued to divide along sectional lines in the 1820s, although no issue divided the country so deeply as slavery. Politicians who aspired to the presidency could not afford to alienate any section by taking extreme positions on divisive issues. By 1824, the old party system had broken down. The Federalists had disappeared as a national party, and factional disputes plagued the Jeffersonians. No candidate won a majority of the electoral college in a bitter contest that attracted little public interest. In the House of Representatives, in which the election was decided, Henry Clay threw his support to John Quincy Adams, who became the next president.