The US election was plunged into chaos early on Wednesday as President Donald Trump prematurely declared victory and sought Supreme Court intervention to stop vote-counting – even as his Democratic rival Joe Biden voiced confidence in his own chances.

In a divisive election cast under the shadow of the coronavirus pandemic that has claimed more than 230,000 lives in the US, Trump appeared to have avoided a Democratic wave predicted by some polls but he still needs key states to secure another four-year term.

Shattering norms in the world’s most powerful democracy, Trump alleged “major fraud” as he held an upbeat rally inside the White House’s ceremonial East Room.

“We did win this election,” Trump told cheering supporters, few of them wearing masks to protect from Covid-19. “This is a fraud on the American public.”

The Republican tycoon said he would go to the Supreme Court because “we want all voting to stop.”

Voting had already ended by the time Trump took the podium after 2am (0700 GMT) but Trump appeared to be calling for the court to stop counting.

Trump has railed for months against mail-in ballots, charging without evidence that they could be fraudulent, as some 100 million US citizens voted ahead of Election Day amid the health crisis.

The Biden campaign soon hit back, calling the president’s bid to stop vote counting “outrageous” and “unprecedented”, and saying its legal teams were ready to fight him in the courts if need be.

“The counting will not stop. It will continue until every duly cast vote is counted,” it vowed.

Biden had earlier warned that vote counting would take a while as he greeted his own backers, who honked from cars at a socially distanced rally in his home state of Delaware.

“We believe we’re on track to win this election,” the 77-year-old former vice-president said. “Keep the faith, guys, we’re going to win this.”

Biden’s remarks clearly unnerved Trump who immediately tweeted his claims of victory and fraud, leading Twitter to flag his comments as part of its effort against election disinformation.

Governor Tom Wolf of Pennsylvania, which is proving to be the vital prize, said that one million mailed-in ballots remained to be counted and promised that all counties would work “tirelessly” to complete them.

“Let’s be clear,” the Democrat said of Trump’s comments. “This is a partisan attack on Pennsylvania’s election, our votes and democracy.”

Trump for the past four years has often been quick to say he is treated unfairly but even a few of his allies voiced unease at his dramatic intervention.

“Stop. Full stop. The votes will be counted and you will either win or lose. And America will accept that. Patience is a virtue,” tweeted Adam Kinzinger, a Republican congressman who won reelection.

Foreign countries also sounded the alarm, with German Defence Minister Annegret Kramp-Karrenbauer warning that Trump could create a “constitutional crisis.”