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.