Stephen Miller taping Sunday-show interviews from the White House. REUTERS/Joshua Roberts One of President Donald Trump's most controversial advisers helped him draft a letter to FBI Director James Comey in May explaining his firing, but the White House counsel thought it was problematic and ultimately blocked it from being sent.

Robert Mueller, the special counsel leading the FBI's investigation into Russia's election interference, obtained the letter, according to The New York Times, most likely as part of his ongoing efforts to determine whether Trump sought to obstruct the investigation when he fired Comey in May.

It is not clear how much — if any — of the letter referred to the Russia probe. The Times reported on the existence of the letter on Friday but did not appear to have obtained a copy.

Stephen Miller, Trump's policy adviser who's an ally of Steve Bannon, the former White House chief strategist, helped draft the letter, The Times said. Miller has emerged as a hardline and exceedingly loyal player in the Trump administration. Given Trump's displeasure with Comey leading up to his firing, it is likely that Miller helped Trump draft a letter that appealed to his more incendiary instincts.

The Wall Street Journal reported Thursday that Trump's legal team was trying to fend off an obstruction-of-justice charge from Mueller's investigators by arguing that the president has the authority to fire whomever he wants, and that Comey — who told the Senate Intelligence Committee earlier this summer that Trump pressured him to lay off the investigation into Michael Flynn, the former national security adviser — is an unreliable witness.

In a tweet on Friday, Trump criticized Comey based on a claim that he decided to end the investigation into Hillary Clinton's use of a private email server as secretary of state before the FBI interviewed her.

"A rigged system!" Trump wrote.

The administration's explanation for Comey's dismissal — which shifted in the days afterward and was ultimately undermined by Trump — has persisted as one of the more damaging missteps of the White House's early months.

The White House counsel, Don McGahn, prevented Trump from sending the letter he wanted to, according to The Times — so Attorney General Jeff Sessions and Deputy Attorney General Rod Rosenstein were enlisted to provide the justification for Comey's firing instead.

The letters they wrote outlining Comey's mishandling of the Clinton email investigation were initially presented as the impetus for his dismissal. Sean Spicer, the White House press secretary at the time, told reporters at first that the Department of Justice — specifically Rosenstein — had determined Comey needed to go because of how he handled that probe.

In an interview with NBC's Lester Holt two days later, however, Trump acknowledged that he was going to fire Comey "regardless" of the recommendations from Rosenstein and Sessions. He called Comey "a showboat" and "a grandstander" and said he fired the director because the FBI was in "turmoil." (The acting director at the time, Andrew McCabe, later denied that the bureau had lost faith in Comey before his firing.)

Trump made his displeasure with Comey clear even before the director testified before the Senate Judiciary Committee just before his firing. Trump said in tweets the night before the hearing that Comey "was the best thing that ever happened to Hillary Clinton in that he gave her a free pass for many bad deeds."

"The phony Trump/Russia story was an excuse used by the Democrats as justification for losing the election," he added. "Perhaps Trump just ran a great campaign?"

The next day, Comey confirmed in the open — and televised — hearing that the FBI was still investigating whether there was "any coordination" between the Trump campaign and Russian officials during the election. Comey had not allowed the White House to preview his testimony, which Trump and his aides considered "an act of insubordination," according to Reuters. The Times echoed that report, saying Trump was broadly irked by his inability to gain assurances of loyalty from Comey.