With Donald Trump refusing to commit to accepting the election result and both parties primed to deploy an army of lawyers, the US is possibly facing weeks of uncertainty over who will become the country's 46th president.
Unless there is a decisive result, the US will be facing a contested election for the second time in 20 years, with the result being decided in the Supreme Court - or even in Congress.
There is machinery in place to ensure a president is finally chosen, but the road to the inauguration on Jan 20 will have plenty of twists and turns.
It's all down to the Founding Fathers
US elections are not decided by the popular vote, but by the Electoral College, a system put in place by the Founding Fathers of the United States at the 1787 Constitutional Convention.
It was established at a time when the direct election of a country's political chief executive was unheard of and the Electoral College - the gathering together of a temporary group of electors for the purposes of choosing a president - was, in reality, a compromise between those who wanted the power vested in Congress and those who wanted something more democratic.
Two of the last five elections have been won by a candidate who secured fewer votes than his opponent: George W. Bush in 2000 and Donald Trump in 2016.
It means that the presidential election is, in reality, not one contest but 50 with the result hinging on a few thousand votes in "battleground states", which are likely to be the focus of a flurry of litigation this year.
Have elections been contested before?
Yes, on four occasions.
• In 1800, the election between Thomas Jefferson and Aaron Burr ended in a dead heat, with both candidates securing 73 votes in the Electoral College. The decision went to the House of Representatives, with each state getting one vote in what is known as a contingent election. It is a procedure which could come into play again in a few months' time. It took 36 votes before Thomas Jefferson secured the support of a majority of the 16 state delegations. Burr, who is best known for killing political rival Alexander Hamilton in a duel, became vice president.
• In 1824, Andrew Jackson won both the popular vote and secured more votes than his four rivals in the Electoral College, but failed to secure a majority. It took another contingent election to decide the result and install John Quincy Adams, rather than Andrew Jackson, as president.
• The 1876 election between Republican candidate Rutherford Hayes and Democrat Samuel Tilden is seen as setting a potential precedent for this year. Three states - Florida, Louisiana and South Carolina - sent rival slates to the Electoral College. It was left to Congress to sort the mess out. Voting on party lines, the presidency was awarded to Hayes.
• The hotly contested 2000 election is seen as a foretaste of what might lie ahead in 2020. Everything depended on Florida and the fate of its 25 votes in the Electoral College. It all hinged on thousands of ballots which were thrown out because they had been incorrectly punched by voting machines leaving what were known as "hanging chads". Convinced that they would have won if these votes were reinstated, the Democrats demanded a full recount. The recount was stopped by the Supreme Court six days before the Electoral College was due to meet, leaving Bush 537 votes ahead - and Gore conceded.
There could have been a disputed election in 1960, amid allegations that John Kennedy was the beneficiary of chicanery which even saw dead people vote. But Richard Nixon chose not to do so, accepting the result.
So what could go wrong this time?
Constitutional normality was restored by Gore's decision to concede rather than allow the chaos and partisan infighting to continue.
The concession by a losing candidate has constitutional as well as symbolic importance. It means that the victor can be sworn in on Inauguration Day - which is due to take place on January 20.
There is little sign of Donald Trump being willing to follow Gore's example as he has railed against states' decision to allow people to vote by mail rather than run the risk of contracting the coronavirus by doing so in person.
"We're going to have to see what happens," he said on September 23 when asked if he would commit to a peaceful transfer of power.
"Get rid of the ballots," he added, and there would be a "very peaceful … continuation" of power.
"We want to make sure the election is honest, and I'm not sure that it can be," he said the following day.
"I don't know that it can be with this whole situation - unsolicited ballots. They're unsolicited; millions being sent to everybody. And we'll see."
The legal battles have started even ahead of election day
An army of lawyers is being deployed by both parties to fight it out in the courts, with more than 300 cases filed in 44 states.
The key issue is which votes should be counted. The Republicans, who argue that mail-in voting will pave the way for substantial fraud, are trying to impose the strictest possible limits on which ballots should be allowed.
Even ahead of the election, Republicans were strong supporters of strict ID laws and resisted moves in Florida to allow convicted felons to vote once they had served their sentences.
In several cases, the Republicans have asked courts to stop postal votes being counted after election day in a number of battleground states.
The results have been mixed, with the Supreme Court backing a time limit in Wisconsin but not in North Carolina. For the time being, extra days have been allowed in Pennsylvania, but this could be revisited after polling day with thousands of votes being thrown out.
In Nevada, another pivotal state, the Trump campaign wants absentee ballots in Las Vegas - where the Democrats are expected to rack up votes - thrown out because observers are being asked to stand 25 feet (7.6 metres) away from the count.
What does this mean for election night?
A bewildering array of scenarios has already been discussed, including challenges to extended voting hours put in place to make sure everybody gets the chance to cast their ballot.
The biggest anxiety surrounds what is known as the "red mirage" of Trump claiming victory on the night, assuming he is in the lead, before being swamped by a "blue wave" of Joe Biden postal votes.
Trump's lawyers are expected to step up the fight to prevent contested mail-in votes being counted at all, ensuring the president's re-election.
Biden's lawyers will fight these cases tooth and nail and there will be weeks of uncertainty as the legal battles are played out, ultimately in the Supreme Court where conservatives - since the confirmation of Amy Coney Barrett - have a six-three majority.
Could postal ballots be seized before they are counted?
Bill Barr, the Attorney General, has echoed Trump's claims that mail-in voting will lead to rampant election fraud.
Writing in the Harvard Law Review, Edward Foley, professor of constitutional law at Ohio State University, suggests that Barr could order that the ballots are seized on the grounds that counting them would violate the constitutional rights of those who voted in person.
He could also seize the ballots because he believes they are fraudulent and thus breaking federal law.
Foley believes that if Barr was challenged in the courts, Trump could even use the military to seize ballots deemed to be fraudulent.
Another scenario, he suggests, would see far-right militias try to seize and burn ballots.
Mayhem would ensue.
Might there be violence?
A dispute would raise the temperature and fears are growing that right-wing militias would be ready to take to the streets, especially in states like Michigan and Arizona.
Stores have already boarded up their windows and Walmart has taken guns off its shelves as a precaution.
The militias have already put on a display of force and some experts fear that Trump's exhortation to the Proud Boys militia to "Stand back and stand by" could be seen as a call to arms.
Left-wing activists are unlikely to stand aside and their plans have been set out in a pamphlet called "Stopping the Coup".
The leaflet calls for direct action, reprising protests which have been seen in Minneapolis, Portland, Seattle and other major cities over the past few months.
This, in turn, could see Trump invoke the 1807 Insurrection Act to restore order. On Fox News in September, the president made it clear he is willing to do so.
"We'll put them down very quickly if they do that. We have the right to do that, we have the power to do that if we want."
So what is the timeline?
There is a strict timetable which has to be followed to ensure a president is sworn in on January 20.
Members of the Electoral College gather in their respective states on December 14 to vote for the president and vice president, with the decision due to be rubber-stamped by a joint session of Congress on January 6.
This is normally a routine matter, but there are fears that this may not be the case this year.
Under election law, the states are supposed to agree on their delegations on December 8 - known as "Safe Harbor" day. Should they fail to do so, then the matter is settled by Congress.
Normally this is a formality, but this year there is growing speculation that the dispute could see rival slates of delegates being submitted as disputes over which ballots should be counted remain unresolved.
Such is the febrile atmosphere in the US, there has even been speculation that Republican-controlled legislatures could send their own delegations to the College if the Safe Harbor deadline is not met.
Although such a move would be unprecedented and has been denied by senior Republicans, a Supreme Court ruling in July did give state legislatures "the broadest power of determination" over who becomes an elector.
If there is deadlock, then what happens?
America would face a contingent election - as it did when Thomas Jefferson defeated Aaron Burr in 1800.
It would be left to the newly elected House of Representatives to settle the impasse if neither Biden nor Trump had secured the 270 Electoral College votes required to be declared president.
Irrespective of size, each state gets one vote in the election. On the current arithmetic, this would favour the Republicans, thanks to the party having the majority in 26 state delegations and the Democrats 22, with the other two states - Pennsylvania and Michigan - split evenly.
That, of course, could change next week when the entire membership of the House is up for re-election.
By law, this election should take place on January 6. If for some reason it has to be delayed, then an acting president would be appointed.
So who becomes acting president?
Now it gets complicated.
Under the 1947 Presidential Succession Act, if the House is deadlocked, the post would go to the Speaker of House of Representatives.
Assuming the Democrats retain the House and its members reappoint her Speaker, Nancy Pelosi, an 80-year-old California congresswoman, would become acting president.
It was a possibility floated by Trump as he warned against the dangers of failing to choose a president.
"You know, there is a theory that if you don't have it by the end of the year, crazy Nancy Pelosi would become president. You know that, right?"
But, according to Christopher Galdieri, associated professor of politics at Saint Anselm College in New Hampshire, the Democrats could have another card to play.
"The House can pick anyone to be Speaker; it doesn't have to be a member of the House," he told the Telegraph.
"So if this scenario was unfolding Pelosi could step aside long enough for the House to elect Speaker Biden, who'd then get to be acting president while the contingent election continued."