A federal judge has ordered former President Donald Trump and his lawyer to pay nearly $1 million in sanctions for filing a baseless and frivolous lawsuit against Hillary Clinton and others, accusing them of attempting to rig the 2016 presidential election in Clinton’s favor by defaming Trump.

Judge John Middlebrooks of the U.S. District Court for the Southern District of Florida stated in his ruling that the lawsuit should never have been filed and was done in bad faith for an improper purpose.

Trump’s suit, which sought $70 million in damages, accused Clinton and 30 other defendants of conspiring to “weave a false narrative” during the 2016 election that Trump and his campaign were colluding with Russia in their efforts to win the race.

Middlebrooks in his order Thursday noted that “Mr. Trump is a prolific and sophisticated litigant who is repeatedly using the courts to seek revenge on political adversaries.”

“He is the mastermind of strategic abuse of the judicial process, and he cannot be seen as a litigant blindly following the advice of a lawyer,” Middlebrooks wrote.

“He knew full well the impact of his actions … As such, I find that sanctions should be imposed upon Mr. Trump and his lead counsel, Ms. Habba.”

Under the order, the Republican Trump and Habba, are jointly and severally liable for the total amount of sanctions the judge imposed to cover the defendants’ legal fees and costs : $937,989.39. That amount is about $120,000 less than what the defendants jointly requested for sanctions.

Clinton was awarded $171,631 in sanctions to be paid by Trump and Habba, with most of that money earmarked for Clinton’s attorneys’ fee.

That was the second largest amount awarded in Middlebrooks’ order, which gave the Democratic National Committee, its former chairwoman Rep. Debbie Wasserman Schultz of Florida, and a related corporation $179,685.

“The amount of fees awarded in this case, while reasonable, is substantial,” Middlebrooks noted.

The judge in November had sanctioned Habba and other Trump lawyers $50,000 in favor of another defendant in the lawsuit, Charles Dolan.

He called the legal pleadings filed in the case by Habba “abusive litigation tactics,” and said the original lawsuit and a later, 186-page amended complaint “were drafted to advance political narrative; not to address legal harm caused by any Defendant.”

“The Amended Complaint is a hodgepodge of disconnected, often immaterial events, followed by an implausible conclusion,” Middlebrooks wrote.

“This is a deliberate attempt to harass; to tell a story without regard to facts.”

Habba did not immediately respond to requests for comment on the order.

Trump, who is seeking the 2024 GOP presidential nomination, filed his suit in March against Clinton, who was the 2016 Democratic presidential nominee.

The other defendants included the DNC, Wasserman Schultz, Clinton campaign chief John Podesta, the law firm Perkins Coie, the research firm Fusion GPS, the former FBI officials James Comey, Andrew McCabe, Peter Strzok and Lisa Page, as well as Christopher Steele, the ex-British intelligence agent who authored the notorious “Trump-Russia dossier” opposition research report before the election.

The suit claimed that Clinton and other defendants falsified evidence, deceived law-enforcement agencies and engaged in other skulduggery that made “even the events of Watergate pale in comparison.”

Middlebrooks earlier dismissed the lawsuit against Clinton and all other defendants “with prejudice,” which bars Trump from refiling the complaint.

Middlebrooks’ order is the latest in a series of embarrassing legal setbacks for Trump, which have included the criminal conviction last month in New York state court of his Manhattan-based real estate company, The Trump Organization, for a years-long tax avoidance scheme.

Trump and his company also face a major civil lawsuit by New York’s attorney general for an alleged scheme to misstate the valuation of real estate assets for financial gain, and Trump also is being sued by the writer E. Jean Carroll, who accuses him of raping her in the mid-1990s in New York.

An investigation into whether former President Donald Trump illegally attempted to overturn the results of Georgia’s 2020 election, which he lost, has recently been completed by a state grand jury. Additionally, federal prosecutors are investigating Trump’s efforts to reverse his loss in the national election to President Joe Biden, as well as the removal of government documents to his Florida residence upon leaving office.