President Trump unleashed an extraordinary assault on the integrity of the U.S. election system early Wednesday during an outburst in front about 150 cheering supporters at the White House.

At about 2:20 a.m., the president appeared in the ornate East Room to stake a premature claim to victory, even though millions of ballots had yet to be counted.

He leveled baseless accusations that election officials were attempting to deprive him of the win and vowed to take legal action to halt the process — a threat that raised the specter of a bitter, drawn-out contest in a nation already riven by social divisions and wracked by the novel coronavirus pandemic.

“This is a fraud on the American public. This is an embarrassment to our country,” Trump declared, standing on a stage adorned with American flags and Trump-Pence campaign signs. “We were getting ready to win this election. Frankly, we did win this election.”

The president’s diatribe came after hours of shifting results in which he appeared to have outperformed polling to score key victories in Florida and, possibly, North Carolina, but also gave ground to Democrat Joe Biden, who was on the precipice of a victory in Arizona, which Trump won in 2016. Trump aides grew increasingly angry after Fox News called Arizona for Biden before other networks, a win that would open additional paths to victory for the former vice president.

Trump had remained uncharacteristically muted on social media in the early hours of the election returns, which he watched from the White House residence. But after Biden used a drive-in rally in Wilmington, Del., to tell his supporters to “keep the faith” and urge that all votes be counted, Trump moved to win back the spotlight.

“We are up BIG, but they are trying to STEAL the Election,” Trump wrote on Twitter. Misspelling the word “polls,” he continued: “We will never let them do it. Votes cannot be cast after the Poles are closed!”

Trump issued a new tweet with the spelling error corrected, but his missive earned a Twitter warning noting that the information was “disputed” and might be misleading. Facebook took similar actions on another Trump tweet in which he declared: “A big WIN!”

In the East Room, Trump vowed to take the fight over ballot counting to the Supreme Court, but he did not disclose what his arguments would be. He expressed surprise that votes in many states wouldn’t be counted until at least Wednesday — even though that has been widely predicted for weeks.

The maskless crowd cheered for Trump. He was accompanied by first lady Melania Trump; Vice President Pence; and his wife, second lady Karen Pence. Several Trump allies and aides were present, including chief of staff Mark Meadows, advisers Kellyanne Conway, Newt Gingrich and Corey Lewandowski. Top donors such as Doug Deason were in the front of the room.

Big-screen televisions were tuned to Fox News’s election coverage, playing underneath the glittering chandeliers; Trump’s supporters, some wearing red MAGA hats, reacted to what was on the air.

“I predicted this from the day I heard they sent out tens of millions of ballots,” said Trump, who for months sought to discredit widespread mail-in voting. The president has produced no credible evidence of fraud in the system.

The crowd loudly cheered his claims that he’d already won. Some aides, including Meadows, did not clap for that line.

Trump had seemed emotionally down at times in recent days, aides said, but in the East Room he appeared defiant and energized.

Advisers had warned Trump against declaring victory prematurely, and some were quick to criticize it. Former New Jersey Gov. Chris Christie (R) called it a bad political and strategic decision.

Election officials in some jurisdictions reacted to the president by vowing to continue their counts.

“Philadelphia will NOT stop counting ALL legitimate votes cast by eligible voters,” City Commissioner Al Schmidt wrote on Twitter. “And we will report and report and report until the last vote is counted.”

Analysts said there was no historical antecedent to Trump’s assault on the electoral system. In 2000, lawyers for George W. Bush and Al Gore waged a ferocious legal fight over ballot counting in Florida that went to the Supreme Court, with Bush prevailing by a razor-thin margin in the state and winning the electoral college.

“Trump’s announced ‘victory’ is pure authoritarianism at its worst,” John Dean, who served as White House counsel under President Richard Nixon, wrote on Twitter. “His stop-counting-the-votes actions will fail. He has made clear that his continued presidency is pure want-to-be-Donald-the-dictator. Because he may have a GOP Senate if he succeeds, the USA is in big trouble!”

Fox News anchor Chris Wallace called the election uncertainty “extremely flammable” and added that “the president has just thrown a match into it. He hasn’t won these states.”

Trump had started Tuesday morning with a call to “Fox & Friends” for a pep talk with the friendly news outlet. Working on a few hours’ rest after a marathon day of campaigning Monday, Trump had a raspy voice and a more subdued tone, lacking his usual level of bombast.

Reporters speculated that he was fatigued after holding 14 rallies in three days, or that he was coming off the high of the campaign trail to confront the cold, hard reality of the polling numbers that showed him consistently trailing Biden.

Asked during the day about reports he would seek to declare an early victory before all the votes were counted, Trump demurred — he would only do so “when there’s victory. If there’s victory. I think we’ll have victory.”

“There’s no reason to play games,” he added.

For Trump, the final day of the campaign meant a final chance for the president to rally the faithful, making private calls to key allies and flooding his Twitter feed with videos encouraging supporters to vote.

The president’s campaign said it has moved his election night party from the Trump International Hotel to the White House to get around the local D.C. government’s coronavirus safety regulations limiting crowd sizes. The campaign is expected to pay for the party, which could cost hundreds of thousands of dollars, officials said.

Confined to the White House, a president who has barnstormed through swing states in the final weeks of the campaign was suddenly far more isolated. Workers had erected new security fences to keep the public farther away and create a broader ring of protection around the complex amid concerns about potential election night unrest.

Trump took a quick motorcade excursion across the Potomac River to his campaign headquarters in Arlington, where he greeted staffers who were dressed in blue and red MAGA face masks, with Make America Great Again signs lining their cubicles.

In brief remarks, he railed against a Supreme Court order allowing ballots in Pennsylvania to be counted until three days after the election.

“A lot of shenanigans, a lot of bad things happen with ballots when you say, ‘Oh, let’s devote days and days,’ and all of a sudden the ballot count changes,” Trump said. “You have to have a date [for the election], and the date happens to be November 3rd, and we should be entitled to know who won on November 3rd.”

Asked if he had prepared remarks, win or lose, Trump said: “I’m not thinking about concession speech or acceptance speech yet. Hopefully we’ll be only doing one of those two. And, you know, winning is easy. Losing is never easy. Not for me, it’s not.”