WASHINGTON — President Trump on Friday warned James B. Comey, the F.B.I. director whom he fired this week, against leaking anything negative about him, saying that Mr. Comey “better hope” that there are no secret tapes of their conversations that the president could use in retaliation.

The suggestion that the president may be surreptitiously recording his meetings or telephone calls added a twist at the end of a week that roiled Washington. The president and his spokesman later refused to say whether he tapes his visitors, something Mr. Trump was suspected of doing when he was in business in New York.

“James Comey better hope that there are no ‘tapes’ of our conversations before he starts leaking to the press!” Mr. Trump wrote on Twitter.

Mr. Trump appeared to be referring to an article in The New York Times that said he had asked Mr. Comey to pledge loyalty during a dinner at the White House shortly after the inauguration, only to be rebuffed by the F.B.I. director, who considered it inappropriate.