Based on the opinion polls, it looks like the 2020 US presidential elections is going to be close. Let's look back and see previous elections that were close, contentious, and controversial.
1796: This was the third presidential election and the first contested one. George Washington won the previous two uncontested. The rules of the electoral college (138 votes from 16 states) were different then. Every elector had two votes and they could cast one for the president, and one for the vice-president. The candidate with the most votes became the president, and the second highest vote winner became the vice-president. Also, in some states, the general voting public voted for electors in their ballots, not directly for the president. And, the commitment of the electors weren't that solid as they are now. John Adams, the sitting vice-president won 71 electoral votes and Thomas Jefferson won 68 electoral votes. So, Adams was declared the President and Jefferson was the Vice-President, even though they were contesting against each other. The 12th amendment changed the rules to make electors vote for a party ticket in 1804, but not before another close, confusing, and contentious election in 1800.
1800: In this election, the Thomas Jefferson/Aaron Burr Democratic-Republican ticket ran against the John Adams/Charles Pickney Federalist ticket. The electors had planned strategies to avoid getting their opponent the second highest vote, to prevent what happened in 1796. But then, both Jefferson and Burr got 73 votes, and the election went to the (outgoing) House of Representatives. According to the rules, each state cast one vote, and the winner needed to win 9 votes out of 16. For 35 rounds of voting (and Aaron Burr refusing to stand down), Jefferson could manage only 8. On the 36th ballot, after a lot of behind the scenes frenzy orchestrated to prevent a Burr presidency by Alexander Hamilton (who would later be fatally shot by Aaron Burr in a duel in 1804), Thomas Jefferson eventually won 10 states out of 16. Jefferson was elected president in February 1801, more than two months after the election.
1824: There were four presidential candidates in this election: John Quincy Adams (John Adams' son, and secretary of state), Andrew Jackson, William Crawford, and Henry Clay. The winner would have needed 131 out of the 261 electoral college votes. Andrew Jackson won the most electoral votes (99) and also the most popular votes (41.4%), but the election went to the House of Representatives to elect the President from the top three candidates (Jackson, Adams, Crawford). The winner needed a majority of 13 votes from 24 states. John Quincy Adams did just that, winning 13 states, but not after some behind the scenes lobbying by Henry Clay in favor of Adams. Andrew Jackson and his follower's accused the Adams and Clay of colluding and driving a "corrupt bargain". Jackson would run again in 1828 and win in a landslide.
1860: This is the election that triggered southern secession, and the Civil War. Abraham Lincoln won a majority in the Electoral College (180 out of 330), the most popular votes (40%), but he wasn't even on the ballot in 10 southern states, and won no support there. He had three opponents: Stephen Douglas (30% popular votes, 1 state with 12 electoral votes), John Breckenridge, a pro-slavery southern Democrat (18% popular vote, 11 states with 72 electoral votes) and John Bell (12% popular vote, 3 states with 39 electoral votes). Immediately after Lincoln's election, between December 20, 1860 and February 1, 1861, even before he was inaugurated, seven southern states declared secession and formed the Confederate States of America.
1876: This is considered the most controversial election in the US history. The candidates were Rutherford Hayes (Republican) and Samuel Tilden (Democratic). The election had the highest turnout in US history, at 81.8%, with at least one state reporting 101% turnout. The winner needed 185 out of 369 electoral votes. Although Tilden won the popular vote, he had 184 electoral votes, just one short. Hayes, on the other hand, had 165, with 20 electoral votes from Florida (4), Louisiana (8), South Carolina (7), and Oregon (1 out of 3) were in dispute. The Congress appointed an Electoral commission to settle the disputed votes. The electoral commission eventually did settle it in favor of Hayes, but not before a hard bargain driven by the Democrats to stop reconstruction and move the federal troops out of the south. Remember, the Republican Party (Lincoln's party) was anti-slavery, and the Democratic party represented the interests of the whites in the South. This "Compromise of 1877" determined how the post-reconstruction society and electoral politics developed in the south.
2000: This was the Bush-Gore election that many of us remember. The election was decided when the US Supreme court overturned the decision of the Florida Supreme court to recount around 70,000 rejected ballots. This upheld the previously certified results declaring George W. Bush the winner in Florida by 537 votes, and awarding Florida's 25 electoral votes to him. This gave George W. Bush 271 electoral votes out of 538, and the presidency.
Apart from these six very controversial and contentious elections, there were a few other close elections:
Winner losing the popular vote: Apart from 1824, 1876, and 2000; where the winner lost the popular vote, there were two more instances, one in 1888 (Benjamin Harrison) and in 2016 (Donald J. Trump) where the winner lost the popular votes to their opponents.
Other elections where the winner got less than 50% popular votes: 1844 (James K. Polk), 1848 (Zachary Taylor), 1856 (James Buchanan), 1860 (Abraham Lincoln), 1880 (James Garfield), 1892 (Grover Cleveland), 1912 (Woodrow Wilson), 1916 (Woodrow Wilson), 1948 (Harry Truman), 1960 (John F. Kennedy), 1968 (Richard Nixon), 1992 (Bill Clinton), 1996 (Bill Clinton). In all of these elections, there were third (or fourth party) candidates that polled anything between 0.4% to 20% votes. The last election when a third party candidate won a state (and therefore electoral votes) was in 1968 when pro-segregation George Wallace won in five southern states.
The history of the electoral college is a fascinating one, and is fundamental to the federal structure. It ensures that the smaller states can maintain their rights against the larger and the more populous ones. But a detailed discussion is a much larger topic.