WASHINGTON — President Trump on Thursday offered a new version of his decision to fire James B. Comey, the F.B.I. director, saying he would have dismissed him regardless of whether the attorney general and his deputy recommended it.

In his first extended comments on a move that has roiled Washington, Mr. Trump castigated Mr. Comey, calling him “a showboat” and “a grandstander” who had created turmoil at the bureau. But the president’s description of his decision-making process conflicted with the account provided previously by his aides.

The White House previously said that Mr. Trump acted only after Attorney General Jeff Sessions and Deputy Attorney General Rod S. Rosenstein came to him and recommended that Mr. Comey be dismissed. In the letter dismissing Mr. Comey that Mr. Trump signed, it said he was acting on their recommendation. And Vice President Mike Pence, talking to reporters, also said the president had been following the Justice Department officials’ advice.

But in an interview with NBC News on Thursday, Mr. Trump said that Mr. Rosenstein’s opinion had not mattered.

“I was going to fire Comey — my decision,” he told the anchor Lester Holt. “I was going to fire regardless of recommendation. He made a recommendation. He’s highly respected, very good guy, very smart guy. The Democrats like him. The Republicans like him. He made a recommendation. But regardless of recommendation, I was going to fire Comey.”

The president’s comments were the latest shift in the White House account of the episode. They could have been aimed at reassuring Mr. Rosenstein, who has been reported to be upset at the original White House narrative that made it appear the firing was done at his instigation.

Mr. Rosenstein made a trip to Capitol Hill on Thursday for a previously unannounced meeting with the Republican and Democratic leaders of the Senate Intelligence Committee. In a brief hallway conversation with a reporter, Mr. Rosenstein denied reports that he had threatened to quit.

In the NBC interview, Mr. Trump elaborated on his claim in the letter to Mr. Comey that the F.B.I. director had told him on three occasions that the president himself was not under investigation. The F.B.I. has been investigating whether associates of Mr. Trump and his campaign coordinated with Russia as Moscow orchestrated an effort to intervene in the American election and tilt the election to Mr. Trump.

Mr. Trump said Mr. Comey reassured him first at a private dinner and then two other times during phone conversations. He acknowledged that he had directly asked the F.B.I. director if he was being investigated.

“I said, ‘If it’s possible, would you let me know if I’m under investigation,’” Mr. Trump said. “He said, ‘You are not under investigation.’”

He said Mr. Comey had requested the dinner early in his administration to ask to keep his job, which an F.B.I. director does not have to do because under law he has a 10-year term. “He wanted to stay on as the F.B.I. head,” Mr. Trump said. “I said: ‘I’ll consider. We’ll see what happens.’ But we had a very nice dinner and at that time, he told me I wasn’t under investigation, which I knew anyway.”

In explaining his decision to fire Mr. Comey, Mr. Trump went beyond the reasons outlined earlier in the week about the F.B.I. director’s handling of last year’s investigation into Hillary Clinton’s private email server, making clear he had personal antipathy toward Mr. Comey.

“He’s a showboat,” Mr. Trump said. “He’s a grandstander.”

He added that “the F.B.I. has been in turmoil” since last year, apparently a reference to the controversy over how the Clinton investigation was managed, and “it hasn’t recovered from that.”