Behind closed doors, Rosenstein complained about having to create the document used to justify the former FBI chief's ouster in May 2017, former FBI Deputy Director Andrew McCabe writes, according to the Guardian . Trump's removal of Comey, which came during the bureau's probe into Russian efforts to influence the 2016 election and whether the Trump campaign colluded with the Kremlin, is part of a probe into whether the president obstructed justice.

Deputy Attorney General Rod Rosenstein did not choose to write the heavily scrutinized memo explaining former FBI Director James Comey's firing, but did it under order from President Donald Trump, an upcoming book says.

"He said it wasn't his idea. The president had ordered him to write the memo justifying the firing," McCabe wrote of remarks Rosenstein made at a May 2017 meeting, according to the Guardian.

The newspaper obtained a copy of the former FBI official's book, "The Threat: How the FBI Protects America in the Age of Terror and Trump." The president has repeatedly slammed McCabe, who was fired from the FBI just before his retirement last year.

Trump has often raged about the Russia investigation and asserted that he did not collude with Russia or obstruct justice. He did so again in tweets Friday morning, calling the probe a "GIANT AND ILLEGAL HOAX."

Trump hoax tweet

Rosenstein appointed Robert Mueller, himself a former FBI director, as special counsel for the Russia probe not long after Trump fired Comey.

The Justice Department, special counsel's office and White House declined to comment. The FBI directed CNBC to the Justice Department.

WATCH: Bannon says firing Comey a 'historic mistake'