A federal judge on Thursday awarded former President Donald Trump and one of his top lawyers nearly $1 million for filing a sprawling lawsuit against Hillary Clinton and other perceived political enemies «that should never have been filed.»

US District Judge Donald M. Middlebrooks of South Florida said in his 46-page order that Trump, lead attorney Alina Habba and Habba Madaio & Associates were jointly liable for $937,989 in the lawsuit, which he dismissed in September.

«This case should never have been filed. Its insufficiency as a legal claim was apparent from the start. No reasonable lawyer would have filed it,» Middlebrooks wrote, adding that the lawsuit had «a political purpose.»

He then went on to argue why he believed Trump, and not just his lawyers, was guilty.

«Mr. Trump is a prolific and sophisticated litigator who repeatedly goes to court to exact revenge on his political adversaries. He is the mastermind of the strategic abuse of the judicial process, and cannot be seen as a litigator who blindly follows the advice of a lawyer. He knew full well the impact of his actions,» Middlebrooks wrote. «As such, I believe sanctions should be imposed on Mr. Trump and his lead counsel, Ms. Habba.»

NBC News has asked Habba and a Trump spokesman for comment.

Trump filed a lawsuit in March alleging that in 2016, Clinton, who was the Democratic presidential nominee at the time, and the Democratic National Committee, along with others, orchestrated a «malicious conspiracy» to investigate her campaign’s ties to Russia,» destroying his life» and rigging the election in favor of Clinton.

The initial complaint named numerous defendants, including former FBI Director James Comey and Rep. Adam Schiff, D-Calif.

The sanctions issued Thursday were on behalf of 18 defendants who alleged in a joint motion in October that Trump knowingly filed a «factually unsubstantiated and legally unwarranted claim.»

The defendants had requested approximately $1 million to cover their attorneys’ fees and costs, Middlebrooks said.

Middlebrooks’ order characterized Trump and his lawyers as having engaged in an «ongoing pattern of misuse of the courts» and cited a series of lawsuits filed by Trump. Among them were last month’s defamation lawsuit against the Pulitzer Board and repeated lawsuits against New York Attorney General Letitia James, who investigated and ultimately sued Trump over allegations of bank, tax and insurance fraud.

Such lawsuits, Middlebrooks said, undermined the rule of law, diverted resources «from those who suffered actual legal harm» and painted judges as partisans.