A federal judge dismissed Michael Flynn’s prosecution Tuesday after President Trump’s pardon, but said the act of clemency does not mean the former national security adviser is innocent of lying to FBI agents about his talks with the Russian government before Trump took office.

In formally ending Flynn’s three-year legal saga, U.S. District Judge Emmet G. Sullivan said he probably would have denied the Justice Department’s controversial effort this year to drop the case, which Democrats and many legal experts said appeared to be an attempt by Attorney General William P. Barr to bend the rule of law to help a Trump ally.

Sullivan expressed deep skepticism about the Justice Department’s stated reasons for abandoning the case, criticizing it for applying a different set of rules to Flynn, who twice pleaded guilty to lying about his contacts with Russia’s ambassador during special counsel Robert S. Mueller III’s probe of 2016 election interference.

The judge also said he was troubled by the government’s “dubious” rationales as well as aspects of its “ever-evolving justifications” that ignored applicable law, appeared to be irrelevant or to contradict prosecutors’ previous statements.

“President Trump’s decision to pardon Mr. Flynn is a political decision, not a legal one. Because the law recognizes the President’s political power to pardon, the appropriate course is to dismiss this case as moot,” Sullivan wrote, adding: “However, the pardon ‘does not, standing alone, render [Mr. Flynn] innocent of the alleged violation.’ ”

The 43-page ruling delivered the court’s final say in the politically charged case, after the Justice Department and Flynn’s defense requested immediate dismissal following Trump’s “full and unconditional pardon” on Nov. 25. The action ensured that Flynn will not face federal penalties for “any and all possible offenses” arising from facts or circumstances “in any matter related” to Mueller’s Russia probe.

President Trump on Nov. 25 granted a full pardon to former national security adviser Michael Flynn, who pleaded guilty to lying to the FBI back in 2017. (Reuters)

On Twitter, Trump and Flynn exchanged congratulations and shared grievances.

“Thank you and congratulations to General Flynn,” Trump tweeted. “He and his incredible family have suffered greatly!”

“You and your family & our entire nation have suffered greatly and it has to stop,” Flynn replied. “The American people deserve far greater respect from the institutions of our own Government and the Media!”

Flynn, 61, pleaded guilty in December 2017 to lying in an FBI interview and to senior White House officials about the scope of his pre-inauguration conversations with Russian Ambassador Sergey Kislyak after Moscow intervened to boost Trump in the 2016 U.S. election.

Flynn, ousted from the White House after only 22 days on the job, was the only Trump White House adviser charged in Mueller’s investigation, and faced up to six months in prison under an initial plea deal.

But when Sullivan did not initially approve a sentence of probation that had the government’s blessing, Flynn changed defense teams and began accusing prosecutors and his former attorneys of entrapping and coercing him into pleading guilty despite his earlier sworn statements. Flynn moved in January to withdraw his guilty plea, and Barr ordered a review of the case that determined the Justice Department should drop the prosecution.

In reversing course, the Justice Department concluded that Flynn’s lies were not material to any valid counterintelligence or criminal investigation. The government also said it doubted that it could persuade a jury to convict him since key FBI officials who led the probe into potential Trump campaign ties to Russia had been discredited.

Justice Department spokeswoman Kerri Kupec said Tuesday “dismissal is, of course, the correct result.”

In his opinion, Sullivan cast doubt on the government’s stated justifications.

“As this case has progressed, President Trump has not hidden the extent of his interest in this case,” noting that Trump tweeted or retweeted about Flynn’s case at least 100 times. “Given this context, the new legal positions the government took . . . raise questions regarding its motives in moving to dismiss.”

The president has repeatedly attacked the Russia investigation as a “witch hunt” and embraced Flynn’s case as a rallying cry for his reelection campaign. For more than a year, Flynn attorney Sidney Powell has called the pursuit of Flynn a corrupt effort by the FBI and “deep-state” conspirators to “get Trump,” discussing the case several times with Trump, before taking a prominent legal role last month promoting Trump’s unsuccessful claims of voter fraud. Organizers also announced Tuesday that Flynn is expected to speak at a pro-Trump rally Saturday in Washington to protest the election results.

The judge also took issue with the government saying that Flynn had a “faulty memory” in defending his misstatements.

“Mr. Flynn is not just anyone; he was the National Security Advisor to the President, clearly in a position of trust, who claimed that he forgot, within less than a month, that he personally asked for a favor from the Russian Ambassador that undermined the policy of the sitting President prior to the President-Elect taking office,” Sullivan wrote.

Sullivan declined to immediately dismiss the case upon the Justice Department’s motion in May, instead tapping a retired federal judge to argue against the government’s position to help determine whether dismissal was in the public interest. The department argued judges must dismiss prosecutions when the government and defense agree to do so, leading to an extraordinary legal battle that reached the U.S. Court of Appeals for the D.C. Circuit, and raising questions about the power of the courts to check the executive branch.

Former appeals court judge J. Michael Luttig said the case went a long way toward answering those important questions.

“Judge Sullivan did not dismiss the case simply because the government and the defendant agreed, so the government’s position was emphatically rejected, as I believe it should have been,” Luttig said in an email.

Sullivan emphasized Tuesday that courts are not a “rubber stamp.”

Prosecutors conceded at one point, he noted, that judges may act to protect the public against exceptional abuses by “rogue” prosecutors, such as the “corrupt dismissal of politically well-connected individuals.” But Sullivan said that narrow reading “fails to acknowledge the possibility that the ‘considered view of the Executive Branch as a whole’ could be contrary to the public interest.”

Similarly, the judge called the government’s “newly-minted” definition of “materiality” perplexing, “not the law” and an unexplained “about-face” from prior prosecutors’ position that Flynn’s lie’s were “absolutely material” and “went to the heart” of the FBI’s investigation.

Sullivan’s complaints echoed findings by a bipartisan Senate investigation that the Flynn-Kislyak talks were relevant to assessing “what Moscow sought to gain and the counterintelligence vulnerabilities” of Trump’s team. Trump critics noted that the president had the power to pardon Flynn at any point, and should have done so and accepted the political consequences rather than pressing the Justice Department and judiciary to improperly exonerate Flynn.

The Justice Department inspector general found last year the FBI committed serious errors but had sufficient legal basis to open the criminal inquiry into whether individuals associated with Trump’s campaign cooperated with the Russians.

“Pursuant to an active investigation into whether President Trump’s campaign officials coordinated activities with the Government of Russia, one of those officials lied to the FBI about coordinating activities with the Government of Russia,” retired New York federal judge John Gleeson — appointed by the court to argue for the abandoned prosecution — argued in a court filing at one point. “That is about as straightforward a case of materiality as a prosecutor, court, or jury will ever see.”

Former Mueller prosecutor Andrew Weissmann called the ruling a black mark for Barr’s leadership of the Justice Department, saying, “The judicial decision today is confirmation that the Attorney General has debased the independence and integrity of the DOJ to advance the personal interests of the President.”

Sullivan said that while the presidential pardon power is nearly absolute, the Supreme Court in 1915 noted that a pardon “carries an imputation of guilt.”

Sullivan cited the case of former Maricopa County, Ariz., sheriff Joe Arpaio, who Trump pardoned in 2017 of criminal contempt. U.S. District Judge Susan Ritchie Bolton dismissed the case, but said Trump’s pardon does not “blot out guilt,” or in Arpaio’s case, erase a bench trial verdict that found him guilty of ignoring another judge’s order to stop detaining people because he merely suspected them of being undocumented immigrants.

Matt Zapotosky contributed to this report