If there is a tie in the Electoral College, the race for president gets sent to the House of Representatives, where the top three candidates are decided by each state's delegation as a statewide block. As a state, the representatives decide on a candidate to vote for and, after much politicking, one candidate eventually gets a majority of states and becomes president. For vice presidents it's a little simpler: it's only the top two candidates, each senator gets a vote, and whoever gets the majority of Senate votes wins.
Now that that's been dealt with, how did we get to this odd scenario? And are there any ways that it can be made odder?
A LITTLE BACKGROUND
First, as a matter of clarification, the result in November is just a guideline; the real action is in December, when the Electoral College votes. While it would be a political crisis if the Electoral College completely disregarded the will of the people, it's not impossible. Only around half of the states plus Washington, D.C. have laws that explicitly say an elector has to vote for their state's winning candidate. And among those states the laws vary wildly.
In North Carolina, for example, failure to vote for the correct candidate results in a $500 fine and the elector is automatically removed, doesn't have a vote recorded, and a new elector is put in place. In New Mexico, it's a fourth-degree felony for an elector to vote for a different candidate, but there's no provision for canceling the vote. And Ohio just has it as a vague "it's illegal." The Supreme Court has never ruled on the constitutionality of these restrictions, as it has never really mattered and electors tend to be party faithful anyway. But for the following scenarios, it's important to keep in mind:
Our current system is the result of the 12th Amendment, which grew out of the disastrous election of 1800. Article II of the Constitution says that each elector needs to cast two votes and the candidate with the most electoral votes wins, while second place gets the vice presidency. In 1800, the Federalist Adams/Pinckney ticket was up against the Democratic-Republicans' Jefferson/Burr. The Federalists recognized the inherent problem with the then-current rules and gave one electoral vote to John Jay (who wasn't even a candidate), so that Adams would have one more vote than Pinckney. However, the victorious Democratic-Republicans messed that part up and gave Jefferson and Burr the same number of votes, sending it to the House to decide which one of them would be president.
Thirty-six ballots and a truly ridiculous amount of politicking later, Jefferson was finally elected president and Burr vice president. But the flaws in the Constitution were beginning to show, and the 12th Amendment was ratified just in time for the next presidential election. The 12th Amendment changed it so that electors voted for a president and a vice president, as opposed to two presidential ballots. It also created the modern rules for tie-breaking.
WHAT HISTORY CAN TELL US
In the entire history of the country, the Electoral College has only failed to come to an agreement twice, once for president and once for vice president. Weirdly however, they were in two different elections.
The 1836 election pitted Martin Van Buren against a supergroup of Whig opponents specially picked to appeal to specific regions. The plan was to prevent Van Buren from getting a majority in any region so that the House would make the decision. It didn't work and Van Buren won; but when it came time to count the electoral votes, Van Buren's running mate, Richard Johnson, was one vote short of a majority. The entire Virginia delegation had cast their presidential votes for Van Buren and their vice presidential ballots for a different candidate. The election went to the Senate, which picked Johnson in a party line vote.
In 1824, Andrew Jackson won a plurality in both the popular vote and the Electoral College, but not a majority. When it got to the House, they chose second place John Quincy Adams to be president. Accusations immediately started flying that Adams had secured the support of Speaker of the House Henry Clay, who had come in fourth in the race and was thus ineligible to be chosen, in exchange for an appointment as Secretary of State. As for the vice presidency? John Calhoun has been described by one historian as "everybody's second choice" and won Electoral College votes from all sides of the political spectrum, dominating his vice presidential opponents.
WHAT IF THERE'S NO TIE ON ELECTION DAY?
Waking up on Wednesday morning, the newspapers blare "We have a winner!" But that's not the end of the story.
After the contentious 2000 election, with Bush sitting on 271 electoral votes and Gore with 267, there were reports and conspiracy theories of Gore and Democrat consultants trying to flip three electors (for their part, the Gore campaign disavowed the endeavor). This didn't happen (and actually one Gore elector abstained, giving Gore 266 votes), but the fact that it was even tossed around as an idea shows that the Electoral College could in theory make up their own minds regardless of the actual results.
In 1988, it was George H.W. Bush vs. Michael Dukakis and his running mate Lloyd Bentsen. Bush won in a landslide, but one elector flipped their ballot and voted Bentsen president and Dukakis vice president, giving Bentsen one electoral vote for president (the elector, Margarette Leach of West Virginia, did it to protest the Electoral College).
It was inconsequential because the vote was a landslide. But what if it wasn't and the election was tied?
The Constitution says "if no person [has an electoral majority], then from the persons having the highest numbers not exceeding three on the list of those voted for as president" shall the House pick the president. In a no-Electoral College-majority election, the Dukakis-Bentsen flip would have resulted in the House choosing between the top three presidential electoral vote getters—Bush, Dukakis, and Bentsen. In that case, it wouldn't be impossible for the House to decide Bentsen as winner. And although constitutional scholars doubt whether the system would allow such a scenario to take place, Bentsen could in theory also be a vice presidential candidate (the 12th Amendment has the Senate pick between the top two vice presidential vote-getters, so Dukakis would be out).
The Electoral College doesn't need to go down the route of people anyone has actually "voted for"' either. In 1972, one elector cast a vote for the Libertarians, despite them only getting 3674 popular votes in the entire country. But at least they were running for president. In 1976, the two main candidates were Gerald Ford and Jimmy Carter, with Bob Dole and Walter Mondale as the respective VPs. Carter/Mondale walked away from election night the winners with 297 electoral votes to Ford/Dole's 241. But after the Electoral College met, Ford only got 240. This wasn't a repeat of Gore's missing electoral vote or the Dukakis flip—Dole still got 241.
One Washington state (which Ford won) elector voted Ronald Reagan for president, Dole for vice president (Reagan would later tell the elector, Mike Padden, "Boy, we sure gave 'em a go in '76. It came so close"), which illustrates that the Electoral College can pick anyone. And the Bentsen elector actually said, "If 270 women got together on the Electoral College we could have had a woman president."