Kevin Lamarque / AP

In a memo prepared for the president and used by the White House to justify James Comey's firing as FBI director, Deputy Attorney General Rod Rosenstein heavily criticized Comey's behavior during the investigation into Hillary Clinton's use of a personal email server when she was secretary of state.

"I cannot defend the Director's handling of the conclusion of the investigation of Secretary Clinton's emails, and I do not understand his refusal to accept the nearly universal judgment that he was mistaken," Rosenstein wrote.

Rosenstein said Comey was wrong to hold a July 5 press conference last year in which he publicly announced the bureau would not bring charges against Clinton. Rosenstein said that should have been handled by then-attorney general Loretta Lynch and that Comey had broken Justice Department protocols. (Comey later said Lynch had compromised herself publicly by meeting with Bill Clinton on an airplane tarmac.)

White House deputy press secretary Sarah Huckabee Sanders on Wednesday accused Comey of "atrocities in circumventing the chain of command in the Department of Justice."

Rosenstein also said the Comey press conference was wrong because it released "derogatory information about the subject of a declined criminal investigation."

"The Director laid out his version of the facts for the news media as if it were a closing argument, but without a trial," Rosenstein wrote. "It is a textbook example of what federal prosecutors and agents are taught not to do."

Rosenstein also said Comey had been wrong to release an Oct. 28 letter, just days out from the election, announcing the Clinton email investigation would be reopened due to the discovery of emails on the computer of Anthony Weiner, the husband of Clinton aide Huma Abedin. "When federal agents and prosecutors quietly open a criminal investigation, we are not concealing anything," Rosenstein said, disagreeing with Comey that not speaking out would have been tantamount to concealing important information.

"The way the Director handled the conclusion of the email investigation was wrong," Rosenstein wrote of events that happened six months before Comey was ultimately fired and which Trump, as a candidate, celebrated.