Mr. Mattis was “the world’s most overrated general,” Mr. Trump told the group. “You know why? He wasn’t tough enough. I captured ISIS. Mattis said it would take two years. I captured them in one month.”

The conversation, several Democratic officials said, only devolved from there, and reached a fever pitch after Ms. Pelosi told the president that Russia, which has quickly stepped in to fill the void left by American troops in Syria, “has always wanted a foothold in the Middle East.” It was at this point that she told Mr. Trump that all roads with him led to Mr. Putin.

At another point, Mr. Trump told Ms. Pelosi that he cared more about defeating terrorism than she did.

“I hate ISIS more than you do,” the president declared.

“You don’t know that,” the speaker replied.

What happened next is now a matter of ammunition by both the Democrats and the White House.

“You’re just a politician,” Mr. Trump said to Ms. Pelosi.

“Sometimes I wish you were,” Ms. Pelosi shot back.

Mr. Schumer interjected, telling Mr. Trump that name-calling was not necessary.

“Is that a bad name, Chuck?” Mr. Trump asked, then turned to Ms. Pelosi. “You’re not a politician, you’re a third-grade politician.” (Or “third-rate,” depending on which politician was doing the retelling.)

Ms. Pelosi stood up to leave, but then sat back down. At this point Representative Steny Hoyer of Maryland, the House majority leader — who later said he was “deeply offended” by the president’s treatment of the speaker — said it was time to go.