When President Trump’s former national security adviser sat down with special counsel Robert S. Mueller III’s team, the veteran battlefield general was a vulnerable man.

Michael Flynn faced the threat of prosecution for a mounting series of lies and omissions, including about his talks with the Russian ambassador, his private consulting work at the direction of the Turkish government and payments he received from Russian-backed groups. He felt distant from Trump, with whom he once enjoyed a strong bond.

Flynn, who had spent most of his Army career soldiering in Afghanistan and other front lines far from home, also faced another painful reality, according to three people familiar with his plea negotiations: that his son also was in danger of criminal charges.

At some point this fall, Mueller’s team made Flynn a limited-time offer: Come in and make your best case about why you should not be prosecuted, according to people familiar with the discussions who spoke on the condition of anonymity to describe confidential talks.

A whirl of behind-the-scenes negotiations ended Friday with Flynn finalizing a cooperation deal and walking out of court with a single count of lying to the FBI.

He scored what several experts called a highly favorable plea agreement that spares him of many of the criminal charges he could have faced and, for now, leaves his son untouched. In exchange, Flynn agreed to share all he knows about the president and his aides with Mueller as part of his investigation into Russian meddling in the 2016 election.

The deal came as a searing conclusion to what Flynn called Friday “many months of false accusations of ‘treason’ and other outrageous acts.” It hints at the enormous pressure he was under to cooperate.

“Those in Flynn’s orbit should be terrified by today’s development,” said Stephen A. Miller, a lawyer and former federal prosecutor who has specialized in corruption cases. “A structural plea like this is more ominous for President Trump and others than one where the book was thrown at Flynn. Today’s deal signals that Flynn is being rewarded for cooperation deemed highly valuable by Mueller.”

White House attorney Ty Cobb said in a statement that “nothing about the guilty plea or the charge implicates anyone other than Mr. Flynn.”

“The conclusion of this phase of the Special Counsel’s work demonstrates again that the Special Counsel is moving with all deliberate speed and clears the way for a prompt and reasonable conclusion,” Cobb added.

Robert Kelner and Stephen Anthony, Flynn’s lawyers, declined to comment. A lawyer for Flynn’s son, Barry Coburn, also declined to comment.

Flynn was in Mueller’s crosshairs for months. During a voluntary interview with FBI agents a few days into the new administration, Flynn denied having talked about some of the topics that he discussed during the transition with then-Russian Ambassador Sergey Kislyak, according to court filings.

The Washington Post reported in February that Flynn had discussed the Obama administration’s sanctions against Russia with Kislyak in that December call. The Post also reported that then-acting attorney general Sally Yates warned the White House that Flynn had misled senior administration officials about the nature of the contacts.

Flynn was then forced to resign.

Mueller's team was also scrutinizing Flynn for failing to report work that his consulting firm did last year at the behest of the Turkish government. And federal and congressional investigators were examining speaking fees he received from Russia-related entities and failed to disclose, as well as a business trip he took to the Middle East that he failed to disclose on his 2016 security clearance.

Flynn’s legal jeopardy worried Trump. He had mentioned the Flynn probe to FBI Director James B. Comey in the spring and said he hoped Comey could “let this go,” according to Comey’s written testimony to the Senate Intelligence Committee.

In late summer, as Mueller’s grand jury probe grew more active, the president inquired of his advisers about his power to pardon his former aides in the case, according to two people familiar with the discussions.

In late October, amid speculation that Flynn and former campaign chairman Paul Manafort would be indicted, the White House changed its tone slightly. White House lawyer Cobb told the New York Times that the president was not worried about being incriminated by information that Flynn or Manafort might have.

“He likes General Flynn personally, but understands that they have their own path with the special counsel,” Cobb said. “I think he would be sad for them, as a friend and a former colleague, if the process results in punishment or indictments. But to the extent that that happens, that’s beyond his control.”

On Oct. 30, Mueller’s team revealed they had charged Manafort and two other campaign officials in connection to the probe.

At some point, prosecutors warned Flynn that they were prepared to bring charges against him and his son, according to two people briefed on the discussions. Michael G. Flynn Jr. had served as chief of staff of Flynn’s consulting firm and was involved in some of the projects under scrutiny.

Flynn’s lawyers agreed to begin active talks about a deal with Brandon Van Grack, the prosecutor heading the Flynn probe. In such arrangements, lawyers typically offer what information their client can provide. Then, Flynn would have to personally relay that information to prosecutors.

In late November, Trump’s lawyers got wind that Flynn probably was cooperating.

White House lawyer John Dowd called Flynn’s legal team for a sporadic “check-in” call he makes to other defense counsels in the Russia probe every few weeks. Kelner told Dowd that he could no longer communicate with the White House lawyers, according to two people briefed on the discussion. That signaled that Flynn was at least considering sharing information with the special counsel.

Flynn’s lawyers secured considerable concessions from prosecutors in his cooperation deal — a sign that he is providing substantial assistance to the special counsel.

Although Flynn pleaded guilty to a felony that could carry up to five years in jail, prosecutors agreed to recommend that Flynn face from zero to six months, an unusually favorable recommendation. While it does not bind the court, judges often look to prosecutors for guidance when making sentencing decisions.

Flynn’s son is also not expected to be charged, according to a person familiar with the deal.

Late Friday afternoon, Flynn’s son tweeted a picture of himself wearing a baseball cap and a broad smile as he held his baby son.

“Family is the most important thing in life.....don’t ever take yours for granted,” he wrote. “Thanks everyone for the support.”

Josh Dawsey, Rosalind S. Helderman and Tom Hamburger contributed to this report.