Editor's Note: (Julian Zelizer is a professor of history and public affairs at Princeton University and the author, with Kevin Kruse, of the new book "Fault Lines: A History of the United States Since 1974." The opinions expressed in this commentary are his own. View more opinion at CNN.)
(CNN) The shutdown is finally ending. President Donald Trump went on television Friday afternoon and announced he will allow the government to reopen for three weeks.
Although picking winners and losers in politics is always tricky, there is a clear-cut case to be made that House Speaker Nancy Pelosi just completed a masterful political strategy that brought Trump to his knees. The President is going to do what the Democrats have demanded all along: Open the government now, negotiate over border security and the wall later.
Trump leaves the budget battle without getting what he wanted, badly damaged with the electorate, including among some Republican voters, and with the first cracks having emerged among congressional Republicans. This was not how he wanted to head into the year as the investigations into his administration seriously heat up.
How did Pelosi do it? What were the basic strategic moves that she made to so decisively block a President who has survived much longer than his 15 minutes of fame?
The most important factor was that Pelosi did not hesitate to use her political power aggressively. From the start of this process, she has remained steadfast in her insistence that closing the government was not a legitimate way to make demands for new forms of spending.
While sometimes Democrats become leery about seeming too partisan and not being civil enough, Pelosi and the Democrats stood their ground. She drew a line in the sand and stuck by it.
When Trump tried to ignore her first letter about the State of the Union address, she was quick to send a second one with the direct message that he would not be allowed to speak if the doors of government were shut. Institutional power is the primary mechanism through which to restrain a president.
Pelosi also did a good job keeping almost every Democrat in line. She ruled the caucus with an iron fist, making certain that none of her members opted for some kind of bipartisan deal contravening her approach. This kind of party unity is something that the Republicans have perfected, but Democrats can have trouble maintaining.
Not only did she do this with the House, but she also worked closely with Senate Minority Leader Charles Schumer to make sure that members held in the upper chamber. Other than with Joe Manchin, the strategy worked. With discipline, a party can make things very difficult for the President, as Republicans showed under President Barack Obama.
In a refreshing manner, Pelosi also refused to give in to the chaotic frenzy of the Trump White House. The strategy was apparent when she and Schumer met with Trump in the bizarre televised conference in the Oval Office. She sat quietly and let Trump be Trump. She didn't have to say much as the President proudly claimed ownership to the shutdown before it even began.
Since that meeting his statements and misstatements, as well as those of his tin-eared advisers, only hurt the administration's cause. Rather than jumping into each outrageous statement, she remained calm and let the President do her work for her. When he tried to overrule her letter disinviting him to make the State of the Union on January 29, she was clear that he didn't get to set the date and time of the speech just because he wanted it.
The speaker also understood something that Democrats often forget: Americans like their government. While polls usually show that the public opposes government in the abstract, when asked about specific measures such as Social Security or homeland security people sing a different tune.
This is the dynamic that is usually at work with government shutdowns. As the pain of having no government becomes clear -- such as the announcement of airport delays Friday with dizzying maps of planes thrown off course -- people usually become unhappy. Most Republicans remembered this from the shutdowns in 1995-1996 and 2013. Pelosi certainly did. Trump did not. And now he is paying the price.
Many new members of the House were uncertain about voting for Pelosi to be their leader. She quickly quashed the insurgents. But now, in her first official confrontation with Trump, she has proven her chops to all of them. It is no wonder the President has been so reluctant to tweet about her or give her a demeaning nickname. He has seen his top opponent, and the President is scared.