The federal judge presiding over the classified documents case against former US president Donald Trump in Florida dismissed the prosecution on Monday, siding with defence lawyers who said the special counsel who filed the charges was illegally appointed by the justice department.

The decision by US district judge Aileen Cannon, which can be appealed against and may be overruled by a higher court, brings at least for now a stunning and abrupt conclusion to a criminal case that at the time it was filed was widely regarded as the most perilous of all the legal threats the Republican former president confronted.

Though the case had long been stalled, and the prospect of a trial before the November election was an unrealistic scenario, the judge’s order is a mammoth legal victory for Mr Trump as he recovers from a weekend assassination attempt and prepares to accept the Republican nomination in Milwaukee this week.

It is the latest stroke of good fortune in the four criminal cases Mr Trump has faced.

Though he was convicted in May in his New York hush money trial, the sentencing there has been postponed after a Supreme Court opinion that conferred broad immunity on former presidents.

Head and shoulders shot of a woman with a US flag behind her
Judge Aileen M. Cannon dismissed the prosecution (US Senate/AP)

That opinion will result in significant delays in a separate case brought by Mr Smith charging Mr Trump with plotting to overturn his 2020 presidential election loss to Democrat Joe Biden.

Another election subversion case filed by prosecutors in Atlanta has been delayed by disclosures of a romantic relationship between the district attorney and a special prosecutor.

In a statement on his social media platform, Mr Trump said that the dismissal “should be just the first step” and that the three other cases, which he called “Witch Hunts”. should also be dismissed.

He had faced dozens of felony counts accusing him of illegally hoarding classified documents at his Mar-a-Lago estate in Palm Beach, Florida, and obstructing FBI efforts to get them back.

He had pleaded not guilty and denied wrongdoing.

Defence lawyers filed multiple challenges to the case, including a legally technical one that claimed special counsel Jack Smith had been illegally appointed under the Constitution’s appointments clause because he was appointed by attorney general Merrick Garland, rather than being confirmed by Congress, and that his office was improperly funded by the justice department.

“The special counsel’s position effectively usurps that important legislative authority, transferring it to a head of department, and in the process threatening the structural liberty inherent in the separation of powers,” Ms Cannon wrote in a 93-page order granting a defence request to dismiss the case.

“If the political branches wish to grant the attorney general power to appoint special counsel Smith to investigate and prosecute this action with the full powers of a United States attorney, there is a valid means by which to do so,” she added.

That mechanism is through congressional approval, she said.

The order is the latest example of Ms Cannon, a Trump appointee, handling the case in ways that have benefited the ex-president.

She generated intense scrutiny during the FBI’s investigation when she appointed an independent arbiter to inspect the classified documents recovered during the August 2022 search of Mar-a-Lago, a decision that was overturned months later by a unanimous federal appeals panel.

Since then, she has been slow to issue rulings, favouring Mr Trump’s strategy of securing delays, and has entertained defence arguments that experts said other judges would have dismissed without hearings.

In May, she indefinitely cancelled the trial date amid a series of unresolved legal issues.

Mr Smith’s team had vigorously contested the appointments clause argument during hearings before Ms Cannon last month and told the judge that even if she ruled in the defence team’s favour, the proper correction would not be to dismiss the case.

Mr Smith’s team had also noted that the position had been rejected in other courts involving other prosecutions brought by other justice department special counsels.

But Ms Cannon remained unpersuaded, and she called the prosecution’s claims “strained”.

“Both the appointments and appropriations challenges as framed in the motion raise the following threshold question: is there a statute in the United States Code that authorises the appointment of special counsel Smith to conduct this prosecution?” she said.

“After careful study of this seminal issue, the answer is no.”