WASHINGTON ― In case it wasn’t clear what actually happened Friday when President Donald Trump announced he would sign a bill to reopen the government through Feb. 15, we’ve got you covered: the president caved. And House Speaker Nancy Pelosi (D-Calif.) won.

The man who prides himself on his toughness, his virility and his ability to be one step ahead of everyone was outmaneuvered by a liberal woman from San Francisco who mocked his manhood.

Trump dug in against Democrats for 35 days over his demand for $5.7 billion for a border wall in exchange for ending the partial government shutdown. He refused to sign any government spending bill that didn’t have his money. He tried to blame Democrats for hurting the 800,000 federal employees going without pay. He tried to force his way into the House chamber to give a State of the Union address to demand money for his wall.

But every step of the way, Pelosi stopped him. She repeated her mantra ― “public sentiment is everything” ― when Trump tried to shift blame to Democrats, noting how badly the president’s poll numbers were sinking. She called it the “Trump shutdown,” which even he said was fine with him. She told him to stop questioning her “strength.” She denied Trump the ability to preside over her chamber to give a national address, since that power lies with her, not him.

And as talks continued behind the scenes on a way forward, she refused to give the president a dime for his wall in return for ending the longest government shutdown in history.

ASSOCIATED PRESS House Speaker Nancy Pelosi (D-Calif.), confidently leaving the White House after a meeting in December, quickly became a meme with her red coat.

In the end, Trump didn’t just kind of cave; he completely caved. He got nothing for his border wall. He agreed to reopen the government, albeit for just three weeks, while extracting nothing. While he warned there could be another shutdown if he doesn’t get his wall money soon, he gave away his ultimate plan in the same breath ― a national emergency declaration.

Trump suggested if there wasn’t a deal in three weeks, he would declare a national emergency at the border and then use executive authority to redirect military construction money toward a wall. But, as Trump has known for weeks, that sort of move would get tied up in the courts immediately and indefinitely. It would likely take years to sort out whether Trump has this actual authority, and it would set up a precedent for a future Democratic president to declare a national emergency on other issues to bypass Congress.

Trump has said repeatedly he didn’t want to go that route. But with Pelosi holding her caucus together and Senate Republicans showing cracks on Thursday, Trump was forced to capitulate.

“Nobody should underestimate the speaker, as Donald Trump has learned,” Senate Minority Leader Chuck Schumer (D-N.Y.) said shortly after Trump’s announcement.

Pelosi has had a remarkable turnaround since becoming speaker. A few months ago, a vocal (but small) faction of her caucus was determined to prevent her from becoming their leader. There were questions about whether she had been in the job too long and was too toxic with Republicans and independents.

But Pelosi has shattered those doubts and is now more popular than she has been in a decade, according to Gallup polls. And since the election, her favorability rating is up 10 percentage points overall, according to Civiqs, a progressive polling firm.

In a rambling, 20-minute speech in the Rose Garden, Trump tried to make it look like he had actually won the standoff with Democrats. He praised lawmakers for now planning to work on a final Homeland Security spending bill ― which won’t have money for a wall in it. He repeated his nightmare-scenario description of the border as a scene of human traffickers carting around women “with duct tape put around their faces,” a claim experts have debunked. He insisted border security resources are crucial, which Democrats have long said they support.

“If we make a fair deal, the people will be proud of our government for proving we can put our country before party,” Trump declared, even as he’s refused to reopen the government for more than a month.

The House has voted on reopening the government 10 times since Democrats took back the chamber on Jan. 3, and Democrats were unified on nearly every bill, with about a dozen Republicans voting with them. But it wasn’t until Thursday that the Senate held a vote to do so.

Senate Majority Leader Mitch McConnell (R-Ky.) held votes this week on two proposals. One was on a bill Trump had endorsed that included $5.7 billion for his wall plus a three-year extension for the Deferred Action for Childhood Arrivals immigration program. The other was on a bill that was merely a “clean” extension of government funding without wall money.

Trump’s measure got 50 votes, but the clean spending bill got 52 votes, with six Republican senators crossing over. It was a sign that Republicans were losing their shutdown appetite.

He basically lost everything. Rep. Dan Kildee (D-Mich.)

Pelosi’s resistance, of course, wasn’t the only blockade to Trump getting his way. He was under immense pressure from federal workers, who weren’t afraid to speak out about how much the shutdown was hurting them financially. Beyond the political fight, it’s hard to frame anyone as a winner when the government shuts down and leaves hundreds of thousands of people without paychecks.

Airline travel was thrown into chaos Friday after the Federal Aviation Administration had to halt some flights to LaGuardia Airport in New York because of air traffic control staffing shortages related to the shutdown.

A few hours later, Trump announced in the Rose Garden that he’d support exactly the sort of bill he spent 35 days opposing.

“He basically lost everything,” Rep. Dan Kildee (D-Mich.) said on MSNBC on Friday.

HuffPost happened to be with Pelosi during a roundtable with reporters when the news broke of Trump’s decision to reopen the government. She wasn’t one to gloat.

“We’ll see,” Pelosi said when asked if she feels like she won the standoff with Trump.

The California Democrat chuckled when asked if it made her feel good to see hashtags like #QueenPelosi floating around on social media, but said no. Asked how she’s managed to stay one step ahead of Trump through the shutdown, she said it’s just a matter of respecting the institutions of government and understanding who you are talking to.

“Whenever he’s making an accusation, you know he’s projecting his own weakness. His own weakness,” Pelosi said. “He does it all the time.”