The comments represented an extraordinary moment in the investigation, which centers in part on the administration’s contacts with Russian officials: A day after firing the man leading that inquiry, Mr. Trump disparaged him — to Russian officials.

The White House document that contained Mr. Trump’s comments was based on notes taken from inside the Oval Office and has been circulated as the official account of the meeting. One official read quotations to The Times, and a second official confirmed the broad outlines of the discussion.

Sean Spicer, the White House press secretary, did not dispute the account.

In a statement, he said that Mr. Comey had behaved politically and put unnecessary pressure on the president’s ability to conduct diplomacy with Russia on matters such as Syria, Ukraine and the Islamic State.

“By grandstanding and politicizing the investigation into Russia’s actions, James Comey created unnecessary pressure on our ability to engage and negotiate with Russia,” Mr. Spicer said. “The investigation would have always continued, and obviously, the termination of Comey would not have ended it. Once again, the real story is that our national security has been undermined by the leaking of private and highly classified conversations.”

The day after firing Mr. Comey, Mr. Trump hosted Russia’s foreign minister, Sergey V. Lavrov, in the Oval Office, along with the Russian ambassador to the United States, Sergey I. Kislyak. The meeting ignited controversy this week when it was revealed that Mr. Trump had disclosed intelligence from an Israeli counterterrorism operation.