President Trump wrote a letter to then-FBI chief James Comey spelling out his reasons for firing him — but never sent it because his lawyer convinced him it could lead to trouble, a new report said Friday.

And the letter is now in the hands of special counsel Robert S. Mueller, who is probing Comey’s firing as part of his investigation into Russian meddling in the election and possible collusion with the Trump campaign, the New York Times reported.

White House counsel Donald F. McGahn believed parts of the letter — co-written by political adviser Stephen Miller — were “problematic,” the paper reported, citing a dozen administration officials and others familiar with the letter.

McGahn eventually persuaded the president not to send the letter to Comey, who was fired on May 9.

The White House initially said Comey was canned for bungling the investigation into Hillary Clinton’s private email server.

But Trump threw his own communications team under the bus days later, telling NBC News that he fired the top G-man because he wouldn’t call off the Russia investigation.

The Justice Department handed over a copy of the letter to the special counsel’s staff in recent weeks.

Ty Cobb, another White House lawyer, declined to comment on the letter.

“To the extent the special prosecutor is interested in these matters, we will be fully transparent with him,’’ he told the Times, which did not obtain a copy of the letter and was only told of its existence.

Miller drafted the letter at Trump’s request during a weekend in May, when Team Trump was at the president’s private golf club in Bedminster, NJ, according to the report.