WASHINGTON -- A divided federal appeals court on Wednesday ordered the dismissal of the criminal case against President Donald Trump's former national security adviser Michael Flynn, turning back efforts by a judge to scrutinize the Justice Department's extraordinary decision to drop the prosecution.

The U.S. Circuit Court of Appeals for the District of Columbia said in a 2-1 ruling that the Justice Department's move to abandon the case against Flynn settles the matter, even though Flynn pleaded guilty as part of special counsel Robert Mueller's Russia investigation to lying to the FBI.

The ruling, a significant win for both Flynn and the Justice Department, appears to cut short what could have been a protracted legal fight over the basis for the government's dismissal of the case. It came as Democrats question whether the Justice Department has become too politicized and Attorney General William Barr too quick to side with the president, particularly as he vocally criticizes, and even undoes, some of the results of the Russia investigation.

The House Judiciary Committee held a hearing Wednesday centred on another unusual move by Barr to overrule his own prosecutors and ask for less prison time for another Trump associate, Roger Stone. Barr has accepted an invitation to testify before the panel on July 28, a spokeswoman said Wednesday, and he will almost certainly be pressed about the Flynn case.

Trump tweeted just moments after the ruling became public: 鈥淕reat! Appeals Court Upholds Justice Departments Request to Drop Criminal Case Against General Michael Flynn.鈥

Later, at the White House, Trump told reporters he was happy for Flynn.

鈥淗e was treated horribly by a group of very bad people,鈥 Trump said. 鈥淲hat happened to Gen. Flynn should never happen in our country.鈥

Flynn called into conservative commentator Rush Limbaugh's radio show and said the ruling was a good development for him and his family. But he also called it 鈥済reat boost of confidence for the American people in our justice system because that's what this really comes down to - is whether or not our justice system is going to have the confidence of the American people.鈥

U.S. District Judge Emmet Sullivan had declined to immediately dismiss the case, seeking instead to evaluate on his own the department's request. He appointed a retired federal judge to argue against the Justice Department's position and to consider whether Flynn could be held in criminal contempt for perjury. He had set a July 16 hearing to formally hear the request to dismiss the case.

Judge Neomi Rao, a Trump nominee who was joined by Judge Karen LeCraft Henderson, wrote that Sullivan had overstepped his bounds by second-guessing the Justice Department's decision. This case, she said, 鈥渋s not the unusual case where a more searching inquiry is justified.鈥

鈥淭o begin with,鈥 she added, 鈥淔lynn agrees with the government's motion to dismiss, and there has been no allegation that the motion reflects prosecutorial harassment. Additionally, the government's motion includes an extensive discussion of newly discovered evidence casting Flynn's guilt into doubt.鈥

She called Sullivan's scrutiny of the government's request an 鈥渋rregular and searching鈥 step that could force the government to have to publicly justify its decision in this case and others.

鈥淥ur precedents emphatically leave prosecutorial charging decisions to the Executive Branch and hold that a court may scrutinize a motion to dismiss only on the extraordinary showing of harassment of the defendant or malfeasance such as bribery - neither of which is manifest in the record before the district court,鈥 she wrote.

Some critics of the Justice Department's dismissal urged the full appeals court to take up the case and reverse the decision of the three-judge panel, as it is empowered to do.

In a dissent, Judge Robert Wilkins said it appeared to be the first time his court had compelled a lower court judge to rule in a particular way without giving the judge a 鈥渞easonable opportunity to issue its own ruling.鈥

鈥淚t is a great irony that, in finding the District Court to have exceeded its jurisdiction, this Court so grievously oversteps its own,鈥 wrote Wilkins, an appointee of former President Barack Obama.

Flynn was the only White House official charged in Mueller's investigation into ties between the Trump campaign and Russia.

He pleaded guilty to lying to the FBI days after the president's January 2017 inauguration about conversations he had had during the presidential transition period with the Russian ambassador, in which the two men discussed sanctions that had been imposed on Russia by the Obama administration for election interefence.

The Justice Department moved to dismiss the case in May as part of a broader effort by Barr to revisit some of the decisions reached during the Russia investigation, which he has increasingly disparaged.

In its motion, the department argued that Flynn's calls with the Russian ambassador were entirely appropriate and not material to the underlying counterintelligence investigation. The department also noted that weeks before the interview, the FBI had prepared to close its investigation into Flynn after not finding evidence that he had committed any crimes.

But the retired judge appointed by Sullivan, John Gleeson, called the Justice Department's request a 鈥済ross abuse鈥 of prosecutorial power and accused the government of creating a pretext to benefit an ally of the president.

Henderson, the other judge in the majority, had asked skeptical questions of lawyers for Flynn and the Justice Department during arguments earlier this month, raising the prospect she would decide in favour of leaving the case in Sullivan's hands.

But she ultimately ruled in favour of dismissing the case.

------

Associated Press writers Mark Sherman, Colleen Long and Michael Balsamo contributed to this report