(CN) — Senator Bernie Sanders accused President Trump on Thursday of trying to steal the election, saying Trump “is prepared to undermine American democracy in order to stay in power.”

By casting doubt on the validity of mail-in ballots, Trump is “attempting to delegitimize the outcome of this election so that if he loses, he can remain in office,” Sanders said.

“This is not just an election between Donald Trump and Joe Biden,” the Vermont Independent continued. “This is an election between Donald Trump and democracy.”

Sanders’ attack comes at a time when millions of Americans plan to vote by mail for the first time, but Trump has raised questions about whether mail-in voting is trustworthy. That and the fact that a crush of mail-in ballots might result in no winner being declared on election night have raised the specter of a litigated contest as happened in 2000.

In fact, a litigated election “is already happening,” said David Lublin, chair of the government department at American University.

As an example, Lublin pointed to Pennsylvania where the Trump campaign has successfully sued to exclude “naked ballots,” or mail-in ballots returned without an inner-security envelope, and is fighting hard to exclude ballots that are mailed before Election Day but arrive later.

“There could be 100,000 naked ballots” that get thrown out in Pennsylvania alone, Lublin said.

Justin Levitt, a professor at Loyola Law School, has been tracking election-related lawsuits this year on his blog and has already counted some 250 cases.

Trump’s efforts to discard or delegitimize mail-in ballots are presumably tied to the presumption that Democrats are more likely to vote by mail.

“One poll found that only about a quarter of Biden supporters would vote in person on Election Day while some two-thirds of Trump voters planned to vote in person,” Sanders said.

This would be an extreme version of the so-called “blue shift,” a term coined by Ohio State law professor Edward Foley to describe the phenomenon over the last 20 years that late-counted votes — from slow-reporting precincts as well as absentee and provisional ballots — tend to strongly favor Democrats.

In 2012, for example, late-counted votes boosted President Obama’s victory margin by more than 60,000 in both Michigan and Ohio. In the 2018 Senate election in Arizona, Republican Martha McSally led by 15,403 votes on Election Day but late-counted votes gave the victory to Democrat Kyrsten Sinema, who picked up an additional 71,303 votes in overtime.

“If Trump can undermine people’s confidence in the validity of votes cast by mail,” Sanders said, “he will be calling into question the validity of votes that may overwhelmingly support Joe Biden.”

“Let us consider the following scenario,” Sanders went on. “On election night, Trump is ahead in many battleground states based on the votes of those who voted in person on Election Day. All across the television screens people see Trump ahead before they turn in for the night.

“But as more and more mail-in ballots are counted, Trump’s lead falls. Trump then announces, with no proof, that there has been massive mail-in ballot fraud and that these votes should not be counted.”

Sanders continued: “In states where Republicans control the legislature, it is possible that the election results will be ignored because of false accusations of voter fraud and that the legislature itself will use its power to appoint electors pledged to vote for Trump, overriding the will of the people.

“And in the midst of all of this, with the death of Justice Ginsburg, Trump is attempting to push through a Supreme Court justice who may very well cast a vote in a case that will determine the outcome of this election.”

If the election is close, the potential for litigation is great since mail-in ballots are rife with problems. Ballots can potentially be disqualified due to missing signatures, partial signatures (such as “Mike” rather than “Michael”), signatures in the wrong spot, signatures on security envelopes that are supposed to be unmarked, or adding a birthdate rather than the signature date.

Ballots can also be disqualified if they arrive without a postmark or with an illegible postmark.

“We could well see a protracted post-election struggle in the courts and the streets,” Richard Hasen, a law professor at the University of California at Irvine, told The Atlantic. “The kind of election meltdown we could see would be much worse than 2000’s Bush v. Gore case.”

Charles Stewart, founder of the MIT Election Data and Science Lab, made a similar prediction. “I’m sure there will be litigation,” he said. “President Trump has shown he will sue at the drop of a hat, regardless of the merits, and Democrats have an aggressive set of election lawyers.”

But Stewart believes the litigation could end up being a mere sideshow. “There will need to be something really at stake for litigation to gain traction, and that will require a close election plus some sort of fundamental unfairness, rather than a nebulous crying of ‘foul,’” he said.

Lublin observed that the reason the 2000 election was so hotly litigated “was that it was genuinely really, really close.”

To head off post-election chaos, Sanders proposed “a high-level bipartisan and nonpartisan commission to oversee the election to reassure all Americans that it has been carried out fairly.”

Sanders also proposed that all states let election officials begin verifying and tabulating mail-in ballots before Election Day itself so that the full results can be reported on election night. “The faster all ballots are counted, the less window there is for chaos and conspiracy theories,” he said.

Some 18 states — including the swing state of Pennsylvania — don’t allow poll workers to begin verifying mail-in ballots until Election Day, which could delay results for days and allow a candidate to suggest that the late-counted votes are suspect.

Lublin agreed with Sanders’ proposal. “The smarter states allow counties to tabulate ballots in advance but not release the totals,” he said.

Stewart added that the best way to avoid chaos is to make sure that poll workers “are trained in what they need to do and follow it to the letter.”

“A mess will occur if election officials try to cut corners,” he said. “They need to be dedicated to taking it slow and steady so that they will leave very little for the lawyers to litigate over.”