Michael Flynn's case ordered dismissed after appeals court overrules judge

The surprise ruling came as the trial judge had questioned the DOJ's move.

In a surprise ruling, the D.C. Circuit Court of Appeals on Wednesday overruled District Judge Emmet Sullivan and ordered him to accept the Justice Department's motion to dismiss the case against former national security adviser Michael Flynn.

President Donald Trump reacted within minutes, tweeting that the ruling in favor of his first national security adviser, whom the president has repeatedly claimed was investigated and prosecuted unfairly, was "Great!"

Special counsel Robert Mueller charged Flynn with one count of lying to federal investigators in late 2017 – a charge to which Flynn twice pleaded guilty. Critics allege his case is an example of alleged politicization of the Justice Department under Trump and Attorney General William Barr.

The three-judge appeals court panel ruled 2-1 in granting Flynn's motion to overrule Sullivan, with Trump-appointee Judge Neomi Rao authoring the majority opinion for the order -- spelling out how the court believes Judge Sullivan overstepped his authority by appointing an outside former judge to argue against the Justice Department and Flynn's legal team.

"A hearing cannot be used as an occasion to superintend the prosecution’s charging decisions, because “authority over criminal charging decisions resides fundamentally with the Executive, without the involvement of—and without oversight power in—the Judiciary," Rao writes.

Rao also notes the recent evidence surfaced by the Justice Department's separate review of the case should give it the freedom to revisit the integrity of the overall prosecution.

"Each of our three coequal branches should be encouraged to self-correct when it errs. If evidence comes to light calling into question the integrity or purpose of an underlying criminal investigation, the Executive Branch must have the authority to decide that further prosecution is not in the interest of justice,"

The opinion denies one part of the motion from Flynn's attorneys in their request to have Judge Sullivan reassigned from the case entirely.

Judge Robert Wilkins dissented from the ruling, noting the court's extraordinary action to step in in the middle of a process to overrule the lower district court judge before he was able to hold a formal hearing on the DOJ's surprise reversal in the case.

"It is a great irony that, in finding the District Court to have exceeded its jurisdiction, this Court so grievously oversteps its own," Wilkins says. "This appears to be the first time that we have issued a writ of mandamus to compel a district court to rule in a particular manner on a motion without first giving the lower court a reasonable opportunity to issue its own ruling; the first time any court has held that a district court must grant “leave of court” ... without even holding a hearing on the merits of the motion; and the first time we have issued the writ even though the petitioner has an adequate alternative remedy, on the theory that another party would not have had an adequate alternate remedy if it had filed a petition as well. Any one of these is sufficient reason to exercise our discretion to deny the petition; together, they compel its rejection."

The Justice Department is already celebrating the ruling, with DOJ spokesperson Kerri Kupec tweeting the ruling is a "WIN."

It's not clear whether Sullivan will plan to appeal the panel's ruling. asking for a review from the full D.C. Circuit Court of Appeals. An attorney representing Sullivan did not immediately respond to ABC News' request for comment.

Here is the appeals court ruling: