Julian Zelizer is a history and public affairs professor at Princeton University and the author of "The Fierce Urgency of Now: Lyndon Johnson, Congress, and the Battle for the Great Society." He's also the co-host of the "Politics & Polls" podcast. The opinions expressed in this commentary are his own.

(CNN) President Donald Trump should be sweating after the shocking outcome in Alabama's special election. Roy Moore's defeat is a huge blow to him personally and to the GOP as a party.

The fact that this seat, in one of the most deeply red states in the country, just flipped to the Democrats is going to generate immense anger and angst among Republicans who are feeling the bite of the Trump presidency in a very visceral way.

Roy Moore's loss broke through one of the most impenetrable walls in American politics: partisan polarization. The Republicans have sat through the chaos of the Trump presidency, holding back on their frustration because they have remained confident that the party is still in pretty good shape and feeling that they can withstand the body blows, which might come from having Trump in the Oval Office.

As much as the dearth of legislation has hurt the party, the loss of this safe seat from their slim Senate majority will be extremely painful, and Trump will be seen as part of the problem.

Just as his endorsement failed to deliver a win for Moore's primary opponent, Luther Strange, the President's all-out blitz in the past week for the controversial Moore backfired spectacularly. He campaigned hard in the final few days and his endorsement did not mean much. This outcome will raise some frightening red flags for the GOP -- and not the kind that Republicans like to see on election day.

Read More