In the U.S. presidential election of 1800, the Federalists (with John Adams, the sitting president, as the nominee) lost to the Democratic-Republicans (represented by Thomas Jefferson and Aaron Burr). This election was the first time in American history that power passed from one political party to another. Election-results map based on an image from the 1970 National Atlas of the United States.
Jefferson viewed the election of 1800 (one of the most divisive in American history) as a second revolution. Federalists (including the sitting President, John Adams, the first chief executive to live in the White House) wanted the country to have a strong central government while Democratic-Republicans (led by their candidate, Thomas Jefferson) believed that a too-strong federal government was dangerous.
Previously close collaborators, Adams and Jefferson had become partisan disagreers by the late 1790s. (Their friendship, through effort, was later restored and they died, within hours of each other, on July 4, 1826 - fifty years to the day after they both signed the Declaration of Independence.)
The Democratic-Republicans won the 1800 presidential vote. But the country’s first constitutional crisis developed when the 73 Democratic-Republican electors (voting in the Electoral College) each cast one ballot for Jefferson (who had run for President) and one ballot for Aaron Burr (the presumptive Vice-Presidential candidate).
Today, the results of such a process in the Electoral College (this is a PDF link) would be straightforward because electors have separate ballots for president and vice president. Such, however, was not the case in 1800 when ballots did not distinguish between the separate offices. As a result, there was a 73-73 tie for president between Jefferson and Burr.
If the Electoral College is deadlocked, the Constitution requires that a presidential election must be decided by the House of Representatives. There, it took 36 ballots, over the course of a week, before Jefferson was finally declared the winner. He would soon take office as the country’s third president, and the issue of separate ballots was thereafter repaired by the 12th Amendment.
John Adams, wishing like-minded Federalists to maintain positions of importance even when he was out of office, issued many last-minute appointments. Many of those appointments - literally at the “midnight hour” - created new judgeships.
When the newly elected president heard about those appointments, he was not amused.