Joe Biden insisted Thursday that he was on the verge of winning the presidency, urging calm and patience as the final votes were methodically counted. As he did, President Trump made frantic legal claims and promoted unfounded allegations about voter fraud in a number of states where he was losing or seeing his lead swiftly diminish.

Trump on Thursday evening unleashed a tirade from the White House briefing room that was filled with falsehoods about the American electoral system. He claimed that there was widespread fraud in states in which he was losing, but not in those he was winning. He provided no evidence for any of his statements.

“If you count the legal votes, I easily win,” he said, in remarks that contained so much fabrication that several networks stopped airing them. “If you count the illegal votes, they can try to steal the election from us.”

After spending months telling Republicans not to vote by mail, Trump said it was suspicious that so many mail-in ballots were for Biden. He suggested corrupt actions were somehow helping Biden cut into his lead in Pennsylvania, while touting that additional votes coming in from Arizona were bolstering his chances.

“We are on track to win Arizona,” he claimed, despite trailing Biden there. He also impugned the integrity of those across the nation who are counting ballots.

Trump claimed Republicans did not lose a seat in Tuesday’s House races (they did), that all of the states too close to call have election systems overseen by Democrats (they don’t), that votes are still being cast (they are not), and that he won Michigan and Wisconsin (he did not).

As Trump spoke, Biden remained in the lead with 253 electoral votes to the president’s 214 — and enjoyed a number of pathways toward winning the 270 needed to secure the presidency. The former vice president maintained his leads in Arizona and Nevada, while Trump’s advantages were diminishing in both Georgia and Pennsylvania. By midnight, Trump’s lead in Georgia was down to about 1,800 votes.

In Pennsylvania, the biggest electoral prize and a state that would give Biden enough electoral college votes to be declared the winner, Trump’s lead had shrunk to less than 23,000 by midnight. Secretary of State Kathy Boockvar (D) said earlier in the day that almost all votes would be tallied by Friday, but that there might be enough results Thursday night for networks to declare a winner.

With tension high in states that remained too close to call, weary election officials continued tallying results Thursday, at times with police protecting them from protesters as the presidency hung in the balance of final tabulations.

Biden’s campaign has expressed increasing optimism that a victory was imminent, creating a website to promote the work of his transition team. Biden and his running mate, Sen. Kamala D. Harris (D-Calif.), on Thursday held a briefing at a theater in Wilmington, Del., with a team of health and economic advisers to discuss the ongoing coronavirus crisis.

It was a visible sign of what his campaign hoped to project: Biden soberly preparing to transition into the White House. Trump, before his remarks Thursday, had not been seen in public since the early morning hours of Wednesday, when he gathered with supporters at the White House and declared he had won.

“Democracy is sometimes messy. Sometimes it requires a little patience, as well,” Biden said Thursday afternoon following his briefing.

“We continue to feel very good about where things stand. And we have no doubt that when the count is finished, Senator Harris and I will be declared the winners,” he added. “So I ask everyone to stay calm — all people to stay calm. The process is working. The count is being completed. And we’ll know very soon.”

Biden campaign manager Jen O’Malley Dillon displayed several slides to reporters earlier in the day, demonstrating how they think Biden will win at least three of the remaining five most competitive states. She said their calculations showed Biden’s lead might narrow in Arizona and ­Nevada, particularly as results from more pro-Trump rural areas are counted, but they remained confident that returns from urban strongholds would help protect their lead.

“We don’t really care which state takes us over the top. We just want to keep going and make sure the counts get done,” O’Malley Dillon said. “We know that it’s going to take a little bit of time and we support that, and we’re just going to stay calm and be patient.”

Biden and other Democrats got a bit of good news Thursday, as Sen. David Perdue (R-Ga.) fell below the 50 percent mark in his bid for reelection. If that holds once counting is completed, it would trigger a runoff in January. A second Georgia Senate race is already expected to lead to a runoff.

Democrats lost multiple Senate races on Tuesday, and their chances of drawing a 50-50 split in the Senate would rest on winning both of those races.

The legal wrangling also continued on Thursday, with Trump’s campaign attempting to sow doubt in the election count in a way that could both seek to change the results as well as produce an explanation for a loss.

Biden campaign attorney Bob Bauer accused Trump’s campaign of engaging in “meritless” lawsuits meant to misinform the public and disrupt the vote count.

“This is part of a broader misinformation campaign that involves some political theater,” he said, adding that the Trump camp has provided no evidence of wrongdoing.

“All of this is intended to create a large cloud that, it is the hope of the Trump campaign, that nobody can see through,” he added. “But it is not a very thick cloud. It’s not hard to see what they’re doing. We see through it. So will the courts, and so do election officials.”

Offering no specific evidence, several Trump allies have claimed that voter irregularities have impacted the tally in states including Pennsylvania, Wisconsin, Georgia and Nevada. The campaign has filed lawsuits in several of those states attempting to halt or alter the vote-counting process.

“These magical sacks of ballots that keep popping up in corrupt and crooked localities that are run by partisan Democrats — we’re going to have eyes on them,” Trump campaign senior adviser Jason Miller told reporters Thursday, making broad accusations with no specific evidence. “And we’re going to make sure they’re not able to pull a fast one on the American people.”

The campaign touted a legal ruling in Pennsylvania that allowed Republican operatives to get a closer look at the ballot-counting process. A judge in Georgia dismissed a separate lawsuit filed by the Trump campaign on Thursday. The lawsuit alleged voter fraud in a few dozen ballots but lacked evidence.

For his part, Trump for a second straight day tweeted his displeasure from the White House.

“STOP THE FRAUD,” he tweeted Thursday afternoon, providing no specifics in a comment deemed by Twitter as misleading. Hours earlier he tweeted “STOP THE COUNT.”

Trump and his allies took issue with the counting of mail-in ballots after Election Day, claiming that the standard process of tallying those votes was a sign of voter fraud.

“ANY VOTE THAT CAME IN AFTER ELECTION DAY WILL NOT BE COUNTED!” Trump wrote on Twitter, another tweet that the social media platform hid after determining it was false or misleading.

In reality, election officials commonly take days, if not longer, to count ballots cast by mail. This year those mail-in ballots had to be counted after Election Day in part because Republican state lawmakers in Michigan, Wisconsin and Pennsylvania blocked election officials from getting a head start on processing and sorting ballots before then. In states that allowed early processing, such as Republican-led Ohio, mail-in votes were tallied on Election Day.

The Trump campaign on Thursday did secure a ruling in Pennsylvania that allowed them access to watch votes be counted in the state, as long as the observers are six feet away and wear masks in accordance with health guidelines during the pandemic.

Several of their other lawsuits were quickly shot down by judges.

A judge in Chatham County, Ga., denied a Trump campaign suit alleging that ballots had been improperly counted because ballots that arrived after the 7 p.m. deadline may have been mixed in with eligible ballots. The judge determined that the poll watcher cited by the Trump campaign could not provide evidence for the claim.

A judge in Michigan, which was called for Biden on Wednesday, told lawyers for the Trump campaign that she would deny the campaign’s request for an emergency halt in the counting of votes in the state.

Trump campaign advisers held a news conference in Nevada in which they made unsubstantiated claims that votes from dead people and nonresidents had been cast in large numbers. Shortly after the event, Biden’s narrow lead in Nevada widened.

By Thursday evening, after a new batch of votes was tabulated, Biden had a lead of more than 11,000. There were still tens of thousands more votes left to be counted, including about 114,000 mail ballots, 60,000 provisional ballots and 44,000 ballots that need verification in Clark County, the state’s largest county and a Democratic stronghold.

The numbers could grow further, since election officials in Nevada must count any mail ballot that was postmarked by Election Day and arrives by Nov. 10.

“Our goal here in Clark County is not to count fast. We want to make sure that we’re being accurate,” said Joe Gloria, the county’s registrar of voters, warning final counts might not be done until this weekend. “Obviously, we are going to be very important to the entire country and that is our number one goal.”

If the remaining states remain extremely tight, calling the race could be further complicated because tens of thousands of ballots were caught in U.S. Postal Service processing facilities until the day after Election Day, according to new data filed in federal court.

In Pennsylvania, 6,877 ballots were processed on Nov. 4. That number was 5,915 in North Carolina, 9,037 in Nevada and 1,706 in Georgia. Those votes — which could count in some states but not others depending on local ballot deadlines — could loom large in tightening races.

The Postal Service processed close to 150,000 ballots nationwide on Wednesday, with a 94.5 percent on-time rate, an improvement over recent days, but still below the 97 percent that postal and voting experts expect of the agency.

But in the nine postal districts spanning five swing states yet to be decided — Arizona, Nevada, Pennsylvania, North Carolina and Georgia — the ballot on-time rate was 84.6 percent. That means roughly 15 out of every 100 ballots in processing plants were not sorted — or delivered — on time.

In filing the data, Justice Department lawyers representing the Postal Service in the U.S. District Court for the District of Columbia cautioned that the figures were not reliable. The data does not include “first mile” and “last mile” handling steps, which could add time to delivery, and only accounts for items the agency was able to successfully identify as ballots.

The Postal Service also encouraged post offices to cull local ballots by hand and deliver them directly to vote counters, bypassing the regional facilities that account for processing scores, though the agency cannot say how widely that practice was being employed.

Jacob Bogage, Emma Brown, Tom Hamburger and Michelle Ye Hee Lee contributed to this report.