Special counsel Robert S. Mueller III on Tuesday recommended that former national security adviser Michael Flynn serve no prison time, citing his “substantial assistance” with several ongoing investigations, according to a new court filing.

Flynn was forced out of his post as national security adviser in February 2017 after the White House said he misled administration officials, including Vice President Pence, about his contacts with Sergey Kislyak, Russia’s ambassador to the United States at the time.

Since then, Flynn has been cooperating with Mueller’s investigation into Russian interference in the 2016 campaign, and his full account of events has been one of the best-kept secrets in Washington. He is one of five Trump aides who have pleaded guilty in the special counsel probe.

But Tuesday’s sentencing memo was heavily redacted, continuing to shroud in secrecy the details of what Flynn has told Mueller’s team and other prosecutors.

The special counsel wrote that Flynn has provided information for several ongoing investigations — participating in 19 interviews with federal prosecutors and turning over documents and communications.

The filing indicated that Flynn has provided extensive assistance to Mueller, including about matters that were redacted and hidden from public view. It also indicated that he has cooperated with a separate unidentified criminal investigation, the details of which were completely redacted.

Mueller wrote that Flynn had provided “firsthand information about the content and context of interactions between the transition team and Russian government officials,” though the details were largely redacted.

Flynn pleaded guilty in December 2017 to one felony count of making a false statement, despite a longer list of charges he could have faced. Prosecutors said last year they would likely seek a prison sentence between zero and six months.

On Tuesday, the special counsel’s office said that based on Flynn’s assistance, the government was recommending a sentence on the low end of that range, “including a sentence that does not impose a term of incarceration.”

Mueller wrote that Flynn’s guilty plea “likely affected the decisions of related firsthand witnesses to be forthcoming with the SCO and cooperate.”

And the special counsel noted that Flynn’s “early cooperation was particularly valuable because he was one of the few people with long-term and firsthand insight regarding events and issues under investigation by the SCO.”

Flynn’s attorney declined to comment. His son Michael Flynn Jr. tweeted “God is good. To those who have supported us throughout this process . . . Thank you from the bottom of my heart. I will never forget you.”

An attorney for President Trump did not immediately respond to a request for comment.

As part of his investigation, Mueller has been working to determine whether any of Trump’s allies coordinated with Russia or sought help for his campaign. Prosecutors have sought to learn whether Trump urged Flynn’s outreach to the Russian ambassador to signal that the new White House team would go easy on the Russian government.

During the presidential transition, Flynn had several contacts with Kislyak. In early December 2016, he attended a meeting at Trump Tower in New York, during which Trump’s son-in-law, Jared Kushner, proposed to the Russian ambassador setting up a secret communications channel with the Kremlin, according to people briefed on intelligence reports.

Later in the month, Flynn spoke with Kislyak about U.S. sanctions on Russia and other topics, Flynn admitted in his plea last year. Flynn also told prosecutors that he was in touch with senior Trump transition officials before and after his communications with the ambassador.

In his plea agreement, Flynn said he contacted the Russian ambassador on Dec. 22, 2016, about the incoming administration’s opposition to a U.N. resolution condemning Israeli settlements as illegal and requested that Russia vote against or delay it. Kislyak called back a day later to say that Russia would not vote against the resolution, court records show.

In another conversation, on Dec. 29, Flynn called Kislyak to suggest the incoming president was not a fan of the sanctions imposed by the Obama administration and asked Russia not to escalate the ongoing feud, according to filings.

Russian President Vladi­mir Putin issued a statement Dec. 30 saying Russia would not retaliate against the U.S. sanctions at that time.

The following day, the ambassador called Flynn to inform him of Russia’s decision to honor Flynn’s request, according to the records.

Flynn admitted he had lied to FBI agents about his interactions with the ambassador when they interviewed him just four days after the inauguration, but also asserted that others in Trump’s transition team knew about his talks with Kislyak, according to court filings.

Flynn told prosecutors that a “very senior member of the Presidential Transition Team” had directed him to contact officials from foreign governments, including Russia, about the U.N. resolution on Israel.

That official is also not named, but people familiar with the matter have said it refers to Kushner. According to one transition team official, Trump’s son-in-law told Flynn that blocking the resolution was a top priority of the president-elect.

Flynn also admitted that before speaking with the ambassador on Dec. 29, he called a senior transition official at the Mar-a-Lago resort, where Trump was staying, “to discuss what, if anything, to communicate to the Russian ambassador about the U.S. Sanctions.” Flynn learned that transition members did not want Russia to escalate the situation, according to court papers.

The senior transition official is not identified in records, but people familiar with the matter identified the official as K.T. McFarland, a onetime Flynn deputy.

McFarland, who initially denied to FBI agents ever talking to Flynn about sanctions in the call, subsequently revised her statement and told investigators they may have discussed sanctions, The Washington Post previously reported.

Two major questions were left unanswered by Flynn’s 2017 guilty plea: whether Trump instructed Flynn to call the ambassador and why Flynn lied about the contacts in the first place.

When Flynn pleaded guilty, then-White House lawyer Ty Cobb said the national security adviser’s lies had nothing to do with the president.

“Nothing about the guilty plea or the charge implicates anyone other than Mr. Flynn,” Cobb said.

Trump has repeatedly said he did not urge Flynn to call or discuss sanctions with the Russian ambassador.

“No,” he told reporters in a February 2017 news conference when asked whether he directed the call. “I didn’t.”

Trump said then that he was troubled that Flynn failed to tell Pence about his contacts with the Russian ambassador, but not by the interactions themselves.

“It certainly would have been okay with me if he did it. I would have directed him to do it if I thought he wasn’t doing it,” Trump told reporters. “I didn’t direct him, but I would have directed him because that’s his job.”

A native of Rhode Island who grew up in a large family of modest means, Flynn studied to become an Army officer during college and chose early in his military career to specialize in intelligence. Among his mentors was Gen. Stanley McChrystal, who praised Flynn’s ability in Afghanistan to bond with his soldiers and get results.

He later became director of the Defense Intelligence Agency, but President Barack Obama removed him from that job in October 2014 amid questions about his temperament. He was forced to retire from the Army.

On Tuesday, prosecutors said the court should view Flynn’s “exemplary” public service, including 33 years in the military and combat service, as a mitigating circumstance that would support a lighter sentence. But they noted that Flynn’s history meant he should have had a better understanding of rules of conduct by government officials.

“The defendant’s record of military and public service distinguish him from every other person who has been charged as part [of] the SCO’s investigation,” prosecutors wrote. “However, senior government leaders should be held to the highest standards.”

Flynn’s lie to FBI agents on Jan. 24, 2017, about his contacts with the Russian diplomat set in motion one of the biggest tumults of Trump’s presidency. It stunned senior Justice Department officials, who felt they had to warn the White House. The aftershocks still shadow Trump’s administration.

Two days after Flynn spoke to FBI agents, then-acting Attorney General Sally Yates visited the White House to alert White House Counsel Donald McGahn about Flynn’s dishonesty.

McGahn immediately told Trump, who expressed surprise that the Justice Department was criticizing his choice of advisers just days after he took office.

Trump didn’t act to correct Flynn’s account or remove him until Feb. 9, when The Post revealed Flynn had talked to Kislyak about sanctions and lied about it.

Flynn resigned on Feb. 13, just 24 days in his position, the shortest tenure of a national security adviser on record.

A few days later, Trump hosted then-FBI Director James B. Comey for a dinner, where Comey said that Trump stunned him by asking him to show lenience in investigating Flynn. According to Comey’s later testimony, Trump told his FBI director that Flynn was a good man and said: “I hope you can let this go.”

Mueller will have an opportunity to lay out additional pieces of the evidence he has been gathering later this week. On Friday, prosecutors with the special counsel’s office are scheduled to file a letter to the judge who will sentence Michael Cohen, the president’s former attorney. The letter will outline additional details of Cohen’s cooperation with Mueller’s office.

Also Friday, Mueller’s team will submit a filing to a judge in Washington describing ways that Trump’s former campaign chairman, Paul Manafort, lied to prosecutors after pleading guilty in September and promising to cooperate. Prosecutors have said that Manafort breached his agreement by continuing to be dishonest in meetings with prosecutors.