In retrospect, one of the signs that Donald Trump would inevitably fail to get what he wanted out of the partial government shutdown was his inability to come up with a nickname for House Speaker Nancy Pelosi. The president's carnival-barker mind, which had produced mud-stained gems like "Crooked Hillary" and "Little Marco," couldn't summon up a more damning burn than merely "Nancy."

Trump and his allies likely have other names for her in private after the president announced Friday he was supporting a re-opening of the federal government for three weeks while Congress continued to debate his unhinged campaign vow for a wall along the Mexican border. It's very difficult to spin this as anything but a surrender on Trump's part. After five weeks of chaos, during which federal workers and the country as a whole suffered, Trump ended up right back where he started, without the wall he wants so badly. The White House has Pelosi to thank for their humiliation—as she has done so many times before, she held the Democrats together, navigating a complicated political situation that ended with the other side's total defeat.

Pelosi, a longtime Democratic leader from San Francisco by way of Baltimore, has long been a bogeywoman to Republicans, who frequently feature her in attack ads in districts where it's assumed her liberal policies—and current home city—don't have much support. But Pelosi is less an ideologue than the liberal version of Republican Senate Majority Leader Mitch McConnell. That is, she's a ruthlessly effective legislative leader who understands how to operate in a DC political knife fight.

We saw this ability after the 2018 midterms—the Democrats retook the House despite plenty of anti-Pelosi ads—when she easily defeated a muddled challenge to her leadership from mostly moderate Democrats, thanks at least in part to her legendary skill at fundraising. But getting donors to open their wallets is arguably the least of her talents.

Pelosi's victory over Trump on the shutdown isn't the first time she's bested a president in humiliating fashion. For that, we need to go all the way back to 2005, when George W. Bush proposed the privatization of Social Security after claiming, not unreasonably, that he had political capital to spend upon being re-elected. As Peter Beinart recently wrote in the Atlantic, Pelosi, then the House minority leader, defied the conventional pundit wisdom by refusing to produce a counter-proposal to address the possibility of Social Security running out of money. If she had proposed something to cut benefits or raise taxes, it would have been unpopular and perhaps made Bush's privatization scheme look good by comparison. Instead, she let Bush's own unpopular proposal twist in the wind and get widely condemned, a choice that no doubt helped Democrats take control of the House in 2006, giving her the Speaker's gavel.

Her first stint as Speaker put her in charge of passing Barack Obama's Affordable Care Act (ACA) through the House, one of the most complex political tasks in American history. At the time, a focus of the debate was the "public option," the term for allowing anyone to buy insurance from the government, who might (public option advocates argue) be able to provide better coverage for less money than for-profit private insurers. Republicans and some Democrats opposed the public option because they thought that government competition would drive private insurers out of business—to which some public option advocates said, well, that's the point.

In November 2009, Pelosi passed a bill containing the public option by a tiny 220-215 margin. To get the public option, she had to make a tough compromise and allow the insertion of an amendment that would prevent insurers involved in the ACA marketplaces (or **"**exchanges") from covering abortion. (At the time, there were far more anti-abortion Democrats in Congress than there are today.) But though the Senate was also dominated by Democrats, there wasn't enough support in Congress's upper chamber for a public option and the Senate ended up passing a more conservative, public option–free bill just before Democrats lost their 60-vote supermajority. That meant the House had to pass its own version of the same bill, a complicated bit of wrangling that involved taking out that anti-abortion amendment in exchange for an executive order banning federal funds from going toward abortion. Again, Pelosi secured just enough votes for the bill to pass, making Obamacare the law of the land.

As those ACA battles showed, Pelosi isn't particularly wedded to every item on the progressive agenda, and is always willing to trade horses, even swap sacred cows. That's earned her plenty of criticism from the left, including newly minted lefty icon Alexandria Ocasio-Cortez, who has pushed Pelosi to do more on climate change, with limited results. If Pelosi is hated by the right, she's also derided by the left for being a typical establishment politician.

That's a little harsh, because Pelosi is an exceptional establishment politician—as shown by how easily she handled Trump during this winter's shutdown.

She started with plenty of leverage. From the beginning, the public blamed the president for the mess, probably because it was Trump's demand for $5.7 billion in wall money that prompted the shutdown, and because Trump said on camera last month, "I am proud to shut down the government," and because Democrats in the House repeatedly voted to reopen the government as a signal they weren't the ones standing in the way.

Still, some Democrats were concerned about the suffering the shutdown was causing, and in particular moderate members of Pelosi's caucus were worried about appearing unreasonable and unwilling to compromise. But the Speaker held Democrats together, refusing to offer Trump any big concessions. Meanwhile, she confronted Trump directly, refusing to let him deliver the State of the Union speech in the House; in response, he forced her to cancel a congressional trip to the Middle East. Effectively, these moves increased Pelosi's stature at Trump's expense, as the State of the Union is much more important than a member of Congress getting on a plane.

This week, it gradually became clear that the Republicans, not the Democrats, would be the ones to crack under pressure. Some of Trump's own voters were against him on the shutdown, and a Democratic proposal to reopen the government without wall money earned more votes in the Senate than a GOP bill that would have built the wall—thanks to a surprising six Republican defections. Less than 24 hours later, Trump made it official and agreed to reopen the government, with the promise that Congress get to work on some kind of compromise on border security and immigration.

Given that such a compromise has eluded Congress for literally decades, it seems unlikely that they'll pass anything into law before they need to pass another funding bill three weeks from now. And it seems even more unlikely that Trump will get what he wants out of those negotiations. Standing in between him and his beloved wall is a barrier named Nancy.

Sign up for our newsletter to get the best of VICE delivered to your inbox daily.