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.

Read More