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.

“This is not useful,” Mr. Hoyer said as he and Ms. Pelosi made for the door.

“Goodbye,” the president responded. “We’ll see you at the polls.”