“It’s incredibly unfair to my reputation after a 21-year career,” Mr. McCabe said. He said the president’s public attacks were aimed at several targets. “The real damage is being done to the F.B.I., law enforcement and the special counsel,” he said.

Mr. McCabe was the F.B.I.’s second in command during one of the most tumultuous periods in the bureau’s history. He oversaw investigations into both the Trump campaign and Hillary Clinton’s use of a private email server — and he dealt with the fallout from both. He became the acting F.B.I. director after the sudden firing of his boss, Mr. Comey, and he publicly contradicted the White House on national television over whether Mr. Comey had lost the support of rank-and-file F.B.I. agents.

Since then, Mr. Trump has repeatedly singled him out for public attack, suggesting that he helped protect Mrs. Clinton from prosecution during the 2016 presidential campaign. As evidence, he pointed to the fact that Mr. McCabe’s wife, Jill, ran as a Democrat for a State Senate seat in Virginia and received hundreds of thousands of dollars from a political committee run by Terry McAuliffe, a longtime ally of the Clintons.

As recently as Thursday, even as the White House said it left Mr. McCabe’s fate in Mr. Sessions’s hands, officials there left little doubt where the president stood. “It is well documented that he has had some very troubling behavior and by most accounts a bad actor,” said the White House press secretary, Sarah Huckabee Sanders.

Mr. McCabe’s lawyer called those comments “vile and defamatory” and said they were intended to put pressure on the Justice Department. “This intervention by the White House in the D.O.J. disciplinary process is unprecedented, deeply unfair and dangerous,” said the lawyer, Michael R. Bromwich.

Mrs. McCabe lost her race and Mr. McCabe was later promoted to deputy director, where he oversaw the investigation into Mrs. Clinton. No charges were filed in that case, and Mr. Trump has pointed to the donations to Mrs. McCabe’s campaign as evidence of F.B.I. bias.