Once it became clear that Doug Jones had won an upset victory over Roy Moore in the Alabama senate race on Tuesday, the immediate question was: How would the president take the news? Donald Trump, after all, was deeply invested in the race to replace former Alabama Senator Jeff Sessions. Elevating Sessions to attorney general seemed like a safe move back in November of 2016. Alabama was a deep red state where, in the presidential election a week earlier, Trump had won 62 percent of the vote to Hillary Clinton’s 34; and in the 2014 Senate election, Sessions had won by a margin that even a communist dictator would admire: 97 percent of the vote.

But as it turned out, Alabama was a double loss for Trump. First, Alabama Republicans rejected Trump’s choice for the primary, Luther Strange, who had been appointed to Sessions’s seat in the interim. Instead, they went with a gleaming-eyed, fanatical Moore, a candidate so Trumpian that even Trump blanched at supporting. But, amazingly, even after credible allegations of child molestation surfaced against Moore, Trump decided that he would support the theocratic candidate, spending his political capital in a rally in neighboring Pensacola, Florida.

As Cornell Law School professor Josh Chafetz noted:

When the voters once again defied Trump, he (or more likely his staff) issued a surprisingly gracious tweet:

This unexpected civility is a form of whistling past the graveyard. Jones’s victory is a huge disaster for Trump for any number of reasons. First and foremost, it reveals that Trump vaunted skills at dominating the media landscape still leave him almost completely powerless in effecting politics and policy. Trump might commandeer the bully pulpit, but it’s not clear that anyone is really heeding his rants. He might even be realizing as much, for he tweeted on Wednesday morning:

Trump’s few areas of actual success, such as court nominations and potentially the tax bill, have involved capitulating decision-making to Republican leaders in Congress. In effect, Trump can only get anything done when he offloads his duties to people like House Speaker Paul Ryan or Senate Majority Leader Mitch McConnell. But Trump’s reliance on the congressional GOP looks riskier now that his Senate margin has shrunk to 51-49. Moreover, with Jones in the Senate, the Democrats have a much better chance of regaining the Senate in 2018. If they do so, they’ll be able to stop Trump’s nominations dead in the tracks, including his judicial nominations. They’ll also be able to investigate the president, aided possibly by a Democratic-controlled House of Representatives.

The upset in Alabama follows the Democratic Party’s victories in statewide elections in Virginia and strong showings in special elections that they narrowly lost in Georgia, Montana, and South Carolina. All these elections show a common voting pattern, with Democratic voters energized and Trump supporters not showing up in anywhere near the same numbers they did in 2016. The story of Alabama is a familiar one in the Trump era: The Republican base is demoralized and divided, while the Democratic base is mobilized and increasingly united.

As Mark Schmitt of the New America notes:

Trump is turning out to be a true disaster for the Republican Party, because his hardcore supporters are numerous enough to win primaries (as they did for both Moore and Trump), but can only be mobilized by a divisive politics that’s alienating a chunk of traditional Republicans while also animating the Democratic opposition. This can only lead political disaster for the Trump led GOP.

In the wake of Moore’s defeat, Republicans will be more divided than ever. Moore supporters like Steve Bannon, the Breitbart CEO and former Trump strategist, had prepared for such a result—and whom to blame for it.

The Republican Party is facing a nightmare 2018 scenario where Bannon-backed populist candidates disrupt the primaries, creating wounds that will make it difficult for the GOP to unify and win general elections.

There’s a final ominous fact about the Alabama election. Moore lost in large part because of the accusations of sexual assault against him. This is an indication of a sea change in American culture, one that bodes ill for a president who notoriously boasted that his celebrity allowed him to grope women with impunity. Seeing Tuesday night’s election results, Trump has every reason to worry that the social forces that took down Moore have the president in their crosshairs.