The U.S. Justice Department on Thursday moved to dismiss its case against Michael Flynn, abruptly ending a prosecution in which the onetime Trump national security adviser twice pleaded guilty only to later seek to back out of his admission that he lied to federal agents.

In a court filing, the Justice Department said it has taken the view that Flynn's statements in a January 2017 interview, in which he was accused of lying about his past communications with Russia's ambassador to the United States, did not merit a criminal prosecution.

"The government is not persuaded that the January 24, 2017 interview was conducted with a legitimate investigative basis and therefore does not believe Mr. Flynn's statements were material even if untrue. Moreover, we do not believe that the government can prove either the relevant false statements or their materiality beyond a reasonable doubt," U.S. Attorney Timothy Shea, the only signatory, said in Thursday's filing.

The Justice Department's move marked a stunning turnaround in a case originally brought by former Special Counsel Robert Mueller's team. It followed the disclosure of internal FBI records that Flynn, along with other Trump allies, pointed to as evidence that the former national security adviser had been set up to lie by federal agents.

The records were unearthed as part of a review Attorney General William Barr had tasked Jeff Jensen, the U.S. attorney in St. Louis, to conduct of the case.

Flynn, a retired Army general who emerged as a fiery booster of Trump's presidential bid, pleaded guilty in late 2017 to lying to the FBI about his contacts with the Russian ambassador to the United States during the transition. As part of his plea deal, he agreed to cooperate with Mueller's team and admitted that he failed to disclose his past lobbying work for Turkey, in violation of the decades-old Foreign Agents Registration Act.

In December 2018, he appeared in Washington federal court for his sentencing. But the hearing was derailed when Judge Emmet Sullivan suggested he was eyeing a sentence with prison time. Flynn asked to delay the hearing to continue his cooperation with the Mueller team.

No new sentencing date had been set for Flynn, who in recent months has pushed to withdraw his guilty plea. Flynn last year fired his lawyers at Covington & Burling and hired Sidney Powell, a former federal prosecutor who had been a critic of the Mueller investigation as a commentator on conservative media sites.

The Justice Department's dismissal of the case, coming before Flynn was sentenced and ahead of a ruling on whether he could withdraw his guilty plea, is sure to draw criticism for undermining a prosecution brought as part of Mueller's investigation into Russian interference in the 2016 election.

The move follows on the heels of U.S. Attorney General William Barr stepping into the prosecution of Roger Stone to suggest a shorter prison term than what career Justice Department lawyers had initially recommended for the longtime Trump confidant, a move that was widely condemned as an example of political interference in a Mueller case.

The four career federal prosecutors involved in Stone's prosecution dropped off the case as Barr moved to intervene in it. One of the prosecutors, Jonathan Kravis, left the U.S. Attorney's Office altogether.

A career prosecutor in the Flynn case, Brandon van Grack, abruptly withdrew from the prosecution shortly before the Justice Department filed its papers moving to dismiss the case. Thursday's filing was signed only by Shea, who formerly worked with Barr at Main Justice.