WASHINGTON (Reuters) - A U.S. judge on Monday dismissed the criminal case accusing Donald Trump of illegally holding onto classified documents, dealing the former president another major legal victory as the Republican seeks a return to the White House.

Florida-based U.S. District Aileen Cannon, who was nominated by 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.

It marked another blockbuster legal victory for Trump, following the July 1 U.S. Supreme Court ruling that as a former president he enjoyed immunity from prosecution for many of his actions in office.

Prosecutors are likely to appeal the ruling. Courts in other cases have repeatedly upheld the ability of the U.S. Justice Department to appoint special counsels to handle certain politically sensitive investigations.

But Cannon's ruling throws the future of the case, which once posed serious legal peril for Trump, into doubt. Smith is also prosecuting Trump in federal court in Washington over his 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, Trump was indicted on charges that he willfully retained sensitive national security documents at his Mar-a-Lago social club after leaving office and obstructed government efforts to retrieve the material.

Two others, Trump personal aide Walt Nauta and Mar-a-Lago property manager Carlos De Olivera were also charged with obstructing the investigation.

Trump's lawyers challenged the legal authority for Attorney General Merrick Garland's 2022 decision to appoint Smith to lead investigations into Trump. They argued the appointment violated the U.S. Constitution because his office was not created by Congress and he was not confirmed by the Senate.

Lawyers in Smith's office disputed Trump's claims, arguing there was a well-settled practice of using special counsels to manage politically sensitive investigations.

The ruling is the latest and most consequential in a series of decisions from Cannon favoring Trump's defense and expressing skepticism about the conduct of prosecutors. The judge previously delayed a trial indefinitely while considering a flurry of Trump's legal challenges.

In an unusual move, she allowed three outside lawyers, including two who sided with Trump, to argue during a court hearing focused on Trump's challenge to Smith's appointment.

Conservative Supreme Court Justice Clarence Thomas also provided a boost to Trump's challenge to the special counsel. In an opinion agreeing with the court's decision to grant Trump broad immunity in the election case, Thomas questioned whether Smith's appointment was lawful using similar arguments to those made by Trump's lawyers.

Garland appointed Smith, a public corruption and international war crimes prosecutor, to give investigations into Trump a degree of independence from the Justice Department under Biden's administration.

(Reporting by Andrew Goudsward; Editing by Scott Malone and Daniel Wallis)

By Andrew Goudsward