For those who study women in politics, it was a notable moment — a behind-the-scenes peek at a powerful woman negotiating with the leader of the free world. Even Hillary Clinton, the 2016 Democratic nominee for president, did not spar with Mr. Trump in quite the same unscripted way. Their televised debates were controlled by moderators.

“We rarely get to see a woman in that level of leadership confronted in that way,” said Debbie Walsh, the director of the Center for American Women and Politics at Rutgers University. “I think this was an example that really speaks to women’s capacity to lead, and to do it civilly, to do it with grace and to be strong and clear.”

Ms. Pelosi was joined at the negotiating session by Senator Chuck Schumer of New York, the Democratic leader, who scored points of his own when he goaded Mr. Trump into declaring that he would be “proud to shut down the government for border security” — an admission that rattled Republicans and may have strengthened Democrats’ negotiating hand. Vice President Mike Pence was also there, sitting silently as the drama unfolded before him.

Throughout, both Ms. Pelosi and Mr. Schumer made clear that they believed it was unproductive to negotiate in public and repeatedly prodded the president to move the discussion behind closed doors. (“We didn’t want to contradict the president when he was putting forth figures that had no reality to them, no basis in fact,” she later told reporters.)

But Mr. Trump barreled ahead. “It’s not bad, Nancy, it’s called transparency,” he told her.

Ms. Pelosi shot back, “It is not transparency when we are not stipulating to a set of facts and when we want to have a debate with you about saying we confront some of those facts without saying to the public this isn’t true.”

As the reviews rolled in, images of Ms. Pelosi emerging from the White House donning sunglasses while wearing a swingy red coat began circulating on Twitter. Later, a triumphant Ms. Pelosi returned to the Capitol, where she met behind closed doors with her Democratic colleagues, whom she regaled with stories.

According to one Democratic aide in the room, she questioned Mr. Trump’s manhood, calling the wall debate “a manhood thing for him.” She also primly likened the meeting to “a tinkle contest with a skunk,” adding, “I was trying to be the mom.”