The result is a blow to Trump, who saw his chosen candidates lose in both the primary and general election. The president first threw his lot in with Senate Majority Leader Mitch McConnell in backing Luther Strange, who was appointed to fill the seat of Jeff Sessions, who Trump had appointed attorney general. By many measures, Moore, a brash, controversial enemy of the establishment, was the more Trump-like candidate. Strange squeaked into a runoff, with Trump’s help, but then lost the race to Moore.

Despite his many flaws—in addition to his dual removals from the bench, Moore has a history of appalling statements about minorities, LGBT people, and others—the Republican seemed to have the general-election edge in Alabama, a solidly GOP state. Then, about a month before Election Day, the race was rocked by a Washington Post story detailing several women’s accounts of teenaged relationships with a 30-something Moore, including one who said that he had brought her to his home when she was 14 years old and guided her hand to touch his penis through his underwear. Soon, other women emerged with similar stories; one said he had sexually assaulted her. Several reports found that Moore may have been banned from a local mall in Gadsden, Alabama, for making teenagers uncomfortable.

The stories coincided with the #MeToo moment of past sexual misdeeds felling powerful men, and they sent Moore’s campaign into a tailspin. Most of the Republican Party abandoned Moore, with Senate Majority Leader Mitch McConnell saying Moore should withdraw, the Republican National Committee withdrawing funding, and National Republican Senatorial Committee Chairman Cory Gardner saying Moore should be expelled from the Senate if elected.

But after Thanksgiving, Moore seemed to recover his stride. He adamantly denied the allegations, in some cases claiming (against all evidence, including his own past statements) not to even know the women. Trump, himself the target of multiple accusations of sexual assault, backed Moore first timidly and then ferociously, and the RNC followed suit.

The final results show that Moore was no more immune to such allegations than most powerful men (the president excepted) have been in recent weeks. It also showed the power of black voters, and the Democratic Party’s surge in enthusiasm in the face of Trump’s agenda. It is, however, difficult to judge the broader significance of the Alabama result. While Jones’s win follows November elections in Virginia in which Democrat Ralph Northam won an unexpectedly strong victory in the governor’s race and Democrats made gains up and down the ballot, the specific circumstances of the Alabama race are largely unrepeatable.

But the result is clearly a disaster for Republicans. Alabama Governor Kay Ivey could have chosen not to have a special election until 2018, but moved it up. (She replaced Robert Bentley, who appointed Strange and then was forced to resign in disgrace—a strange story of its own.) Trump saw his chosen candidate defeated twice. Steve Bannon, his former strategist and Moore’s fiercest backer, also lost, and the result will intensify an ongoing battle for the identity of the Republican Party. Trumpist candidates like Moore have proven formidable in primary elections and vulnerable in general elections, even in deep-red states like Alabama. Jones’s victory narrows the Republican advantage in the Senate to a thin reed.

There is a silver lining for Republicans, though. A Moore victory would have kept the Senate seat in GOP hands, but it would have sent an unpredictable politician, implacably opposed to McConnell, unbeholden to the party, and tainted by sex scandal to Washington—a likely albatross around the GOP’s neck. With Moore as their candidate, Republicans had no good option in the race. It’s possible they ended up with the least worst option, though.