Mr. McCabe, who was later fired from the F.B.I., declined to comment. His memos have been turned over to the special counsel, Robert S. Mueller III, in the investigation into whether Trump associates conspired with Russia’s election interference, according to a lawyer for Mr. McCabe. “A set of those memos remained at the F.B.I. at the time of his departure in late January 2018,” the lawyer, Michael R. Bromwich, said of his client. “He has no knowledge of how any member of the media obtained those memos.”

The revelations about Mr. Rosenstein come as Mr. Trump has unleashed another round of attacks in recent days on federal law enforcement, saying in an interview with the newspaper The Hill that he hopes his assaults on the F.B.I. turn out to be “one of my crowning achievements,” and that he only wished he had terminated Mr. Comey sooner.

“If I did one mistake with Comey, I should have fired him before I got here. I should have fired him the day I won the primaries,” Mr. Trump said. “I should have fired him right after the convention. Say, ‘I don’t want that guy.’ Or at least fired him the first day on the job.”

Days after ascending to the role of the nation’s No. 2 law enforcement officer, Mr. Rosenstein was thrust into a crisis.

On a brisk May day, Mr. Rosenstein and his boss, Mr. Sessions, who had recused himself from the Russia investigation because of his role as a prominent Trump campaign supporter, joined Mr. Trump in the Oval Office. The president informed them of his plan to oust Mr. Comey. To the surprise of White House aides who were trying to talk the president out of it, Mr. Rosenstein embraced the idea, even offering to write the memo about the Clinton email inquiry. He turned it in shortly after.

A day later, Mr. Trump announced the firing, and White House aides released Mr. Rosenstein’s memo, labeling it the basis for Mr. Comey’s dismissal. Democrats sharply criticized Mr. Rosenstein, accusing him of helping to create a cover story for the president to rationalize the termination.