Doug Jones, a Democrat, should not have won a Senate seat in Alabama. Sure, there were polls in the run-up to Tuesday’s special election showing Jones with a ten-point lead, after allegations surfaced that his Republican opponent, the disgraced former judge Roy Moore, had molested and preyed upon teenage girls decades ago. But Alabama, one of the most conservative states in the country, hasn’t had a close race for national office in decades, and the polls are notoriously fickle. Donald Trump won the state by 28 points in the 2016 election. Under normal circumstances—or even slightly abnormal circumstances—a Republican would win.

But these are not slightly abnormal times—they are extremely abnormal ones. So Doug Jones will be the junior senator from Alabama, eking out a narrow victory over Moore, thanks in large part to a surge in African-American turnout. Moore’s voters, meanwhile, didn’t turn out in the numbers he needed, either because of the allegations against him, the fact that he was expected to win in spite of them, or both.

There is no way to overstate the significance of this upset. A Democrat will hold a Senate seat representing Alabama, shrinking the Republican majority to 51. Roy Moore will not hold national office, saving the country from yet another embarrassment. The Democrats’ chances of flipping the Senate in 2018 got a whole lot better, reducing the number of seats it needs to flip to two. The GOP’s tax reform could be in jeopardy. And it shows that the gamble the Republicans took with an utterly compromised figure like Moore—not to mention Donald Trump—was a spectacularly poor one that will result in Democratic victories in 2018 and beyond.

It’s tempting to downplay the importance of Jones’s victory. Moore, after all, was a uniquely terrible candidate. While he undoubtedly reflects the pathologies that have defined the Republican Party over the past decade—most conspicuously in his politics of white grievance and white victimhood—he was in many ways an aberration, equating homosexuality with bestiality, suggesting that Muslims shouldn’t be allowed to serve in Congress, and arguing that families were better off in the slavery era. A run-of-the-mill Republican who supported Trump would likely have prevailed.

Still, over the past year Democrats have shown again and again—most spectacularly in last month’s elections in Virginia—that they can compete anywhere in the country, including Alabama, Montana, and Georgia. Jones ran a model race, and his campaign points to two factors that will play an important role in the 2018 midterms. The first is that Jones, a federal prosecutor who put away two of the KKK members who killed four girls in a Birmingham church bombing in 1963, was a strong candidate who didn’t shy away from his values. Many pundits pointed to his pro-choice beliefs as proof that he was out of step with the voters in his state, but Jones was able to present himself as a politician with integrity in an election where being a politician with integrity mattered. It’s almost a cliche at this point—or at the very least a Twitter meme—but turnout out of the base is crucial, and the Democratic base, in Alabama and elsewhere, is composed of minority voters and women.

The second factor is arguably more important: Republican voters are demoralized because the Republican president is enormously unpopular and the Republican Party has spent the past year doing enormously unpopular things. Yes, the Moore allegations made a big difference in this race. But they obscure the most important aspect of the special election in Alabama, which is that Republican voters are staying home across the country, while Democrats are voting at unprecedented levels.

Right now, the Republican Party is in its worst-case scenario. Trump won the 2016 election in part because he was able to convince many voters that he wouldn’t push typical Republican policies, which voters overwhelmingly recognize as benefiting the rich. Many voters decided that this aspect of his candidacy overwhelmed larger concerns about him personally. But because Trump has governed as a typical conservative Republican while changing nothing about his personality, Republicans are in a bind: Voters hate the president and hate their agenda. Seemingly the only reason they have to vote is tribal antipathy toward the other side. And if that didn’t work in Alabama, where a pro-choice Democrat just won a Senate seat, Republicans are in deep trouble.

There could be some negative consequences from Jones’s victory. With the GOP’s Senate majority down to one vote, Republicans could speed up tax reform and other harmful legislative items. Jones’s narrow victory, in spite of Alabama’s onerous voter ID laws, could result in a surge of calls for even more restrictive voter ID laws designed to curb minority turnout. But right now, none of that matters. Doug Jones won, Roy Moore lost, and the GOP is in deep trouble. That’s what matters.