A judge in Florida has dismissed the criminal case accusing Donald Trump of illegally holding onto classified documents after leaving office in 2021.
It leaves the Republican former president with another major legal victory as he seeks a return to the White House, and comes just days after he was shot at a campaign rally in Pennsylvania.
US District Judge Aileen Cannon, who was appointed to the bench by Mr Trump, ruled that special counsel Jack Smith, who is leading the prosecution, was unlawfully appointed to his role and did not have the authority to bring the case.
Judge Cannon's ruling came two days after Mr Trump was the target of an assassination attempt at a campaign rally in western Pennsylvania.
Mr Trump is set to be formally named the Republican presidential nominee in Milwaukee this week challenging Democratic President Joe Biden in the November 5 US election.
Prosecutors are likely to appeal the ruling. Courts in other cases have repeatedly upheld the ability of the US Justice Department to appoint special counsels to handle certain politically sensitive investigations.
A spokesperson for Mr Smith did not immediately respond to a Reuters request for comment.
Judge Cannon's ruling throws the future of the case into doubt.
Mr Smith is also prosecuting Mr Trump in federal court in Washington on charges involving the former president's attempts to overturn the 2020 election, but his lawyers have not made a similar challenge to the special counsel in that case.
In the documents case, Mr Trump was indicted on charges that he willfully retained sensitive national security documents at his Mar-a-Lago estate after leaving office in 2021 and obstructed government efforts to retrieve the material.
Two others, Mr Trump personal aide Walt Nauta and Mar-a-Lago property manager Carlos De Olivera, were also charged with obstructing the investigation.
Mr Trump's lawyers challenged the legal authority for Attorney General Merrick Garland's 2022 decision to appoint Smith to lead investigations into Mr Trump.
They argued that the appointment violated the US Constitution because Smith's office was not created by Congress and the special counsel was not confirmed by the Senate.
Lawyers in Mr Smith's office disputed Trump's claims, arguing that there was a well-settled practice of using special counsels to manage politically sensitive investigations.
"This ruling flies in the face of about 20 years of institutional precedent, conflicts with rulings issued in both the Mueller investigation and in D.C. with respect to Jack Smith himself," said Bradley Moss, an attorney who specialises in national security.