WASHINGTON -- U.S. President Donald Trump pardoned his former national security adviser Michael Flynn on Wednesday, ending a yearslong prosecution in the Russia investigation that saw Flynn twice plead guilty to lying to the FBI and then reverse himself before the Justice Department stepped in to dismiss his case.

"It is my Great Honor to announce that General Michael T. Flynn has been granted a Full Pardon," Trump tweeted. "Congratulations to @GenFlynn and his wonderful family, I know you will now have a truly fantastic Thanksgiving!"

The pardon, in the waning weeks of Trump's single term, is part of a broader effort by Trump to undo the results of a Russia investigation that shadowed his administration and yielded criminal charges against a half-dozen associates. It comes just months after the president commuted the sentence of another associate, Roger Stone, days before he was to report to prison.

A Justice Department official said the department was not consulted on the pardon and learned Wednesday of the plan. But the official, who spoke on condition of anonymity to discuss internal deliberations, noted that the president has the legal power to pardon Flynn.

The move is likely to energize supporters who have taken up Flynn as a cause celebre and rallied around the retired Army lieutenant general as the victim of what they assert is an unfair prosecution, even though Flynn twice admitted guilt. Trump has repeatedly spoken warmly about Flynn and, in an indication of his personal interest in his fate, asked then-FBI Director James Comey in February 2017 to end a criminal investigation into the national security adviser.

In a statement, Flynn's family thanked Trump "for answering our prayers and the prayers of a nation" by issuing the pardon.

Democrats lambasted the pardon as undeserved and unprincipled. House Speaker Nancy Pelosi called it "an act of grave corruption and a brazen abuse of power," while Rep. Adam Schiff, the Democratic chair of the House Intelligence Committee, said a "pardon by Trump does not erase" the truth of Flynn's guilty plea, "no matter how Trump and his allies try to suggest otherwise."

"The President's enablers have constructed an elaborate narrative in which Trump and Flynn are victims and the Constitution is subject to the whims of the president," House Judiciary Committee Chair Jerry Nadler said in a statement. "Americans soundly rejected this nonsense when they voted out President Trump. "

The pardon is the final step in a case defined by twists and turns. The most dramatic came in May when the Justice Department abruptly moved to dismiss the case, insisting that Flynn should not have been interviewed by the FBI in the first place, only to have U.S. District Judge Emmet Sullivan resist the request and appoint a former judge to argue against the federal government's position and to evaluate whether Flynn should be held in criminal contempt for perjury.

That former judge, John Gleeson, called the Justice Department's dismissal request an abuse of power and said its grounds for dropping the case were ever-evolving and "patently pretextual."

As Sullivan declined to immediately dismiss the prosecution, Flynn lawyer Sidney Powell sought to bypass the judge by asking a federal appeals court to direct him to drop the matter. A three-judge panel did exactly that, but the full court overturned that decision and sent the case back to Sullivan.

At a hearing in September, Powell told Sullivan that she had discussed Flynn's case with Trump but also said she did not want a pardon -- presumably because she wanted him to be vindicated in the courts.

Powell emerged separately in recent weeks as a public face of Trump's efforts to overturn the results of his election loss to President-elect Joe Biden, but the Trump legal team distanced itself from her after she advanced a series of uncorroborated conspiracy claims.

The pardon spares Flynn the possibility of any prison sentence, which Sullivan could potentially have imposed had he ultimately rejected the Justice Department's dismissal request. That request was made after a review of the case by a federal prosecutor from St. Louis who had been specially appointed by Attorney General William Barr.

At issue in the prosecution was an FBI interview of Flynn, days after Trump's inauguration, about a conversation he had during the presidential transition period with the then-Russian ambassador.

Flynn acknowledged lying during that interview by saying he had not discussed with the diplomat, Sergey Kislyak, sanctions that the outgoing Obama administration had just been imposed on Russia for election interference. During that conversation, Flynn advised that Russia be "even-keeled" in response to the punitive measures, and assured him "we can have a better conversation" about relations between the countries after Trump became president.

The conversation alarmed the FBI, which at the time was investigating whether the Trump campaign and Russia had co-ordinated to sway the election. In addition, White House officials were stating publicly that Flynn and Kislyak had not discussed sanctions, which the FBI knew was untrue.

Flynn was ousted from his position in February 2017 after news broke that Obama administration officials had warned the White House that Flynn had indeed discussed sanctions with Kislyak and was vulnerable to blackmail. He pleaded guilty months later to a false statement charge.

But last May, after years of defending the prosecution, the Justice Department abruptly reversed its position.

It asserted the FBI had no basis to interview Flynn about Kislyak and that any statements he made during the interview were not material to the FBI's broader counterintelligence probe. The department also pointed to internal FBI notes showing agents had planned to close out the investigation weeks before interviewing Flynn about Kislyak.

Flynn, of Middletown, Rhode Island, was among the first people charged in Mueller's investigation and provided such extensive co-operation that prosecutors did not recommend any prison time, leaving open the possibility of probation.

But the morning he was to have been sentenced, after a stern rebuke about his behaviour from Sullivan, Flynn asked for the hearing to be cut short so that he could continue co-operating and earn credit toward a more lenient sentence.

After that, he hired new attorneys -- including Powell, a conservative commentator and outspoken critic of Mueller's investigation -- who took a far more confrontational stance to the government and tried to withdraw his guilty plea.