The stunning victory of Democrat Doug Jones over Roy Moore in Alabama's U.S. Senate election on Tuesday marked an enormous setback for Republicans in a state they have dominated for decades.
It's a setback with a silver lining, to be sure.
Here are five big takeaways from the Democrats' capture of the Senate seat vacated by Republican Atty. Gen. Jeff Sessions:
President Trump's troubles with Congress just got worse.
The Republican loss will shrink the GOP's Senate majority to a thin 51-49.
That makes passing laws even harder for a president who was already struggling to keep every GOP senator in line behind his agenda, especially on healthcare and taxes.
It also makes it more plausible for Democrats to seize control of the Senate next November.
Trump's unpopularity had already put the House in play. The 2018 election map makes the Senate a tougher reach for Democrats – but not quite as tough now.
Trump's power to inspire conservatives has limits.
Burned by his decision to back a candidate who lost the GOP primary, Trump gambled on campaigning hard for Moore even as other Republicans withdrew their support when Moore was accused of sexually assaulting teenage girls.
Trump argued that another Democrat in the Senate would thwart his plans to roll back abortion rights, curb illegal immigration and block new gun controls.
Despite Trump's overwhelming victory last year in deeply conservative Alabama, its voters rejected his advice.
Deep South voters rejected Moore's bigotry.
Moore's opponents in Alabama, including some business leaders, feared that electing him would embarrass the state.
It wasn't just the prospect of an accused child molester winning one of its seats in the Senate; it was also Moore's well-publicized history of prejudice.
To those familiar with his inflammatory rhetoric — he once declared Muslims unfit for office — it came as no surprise that during the campaign he called Native Americans and Asians "reds and yellows." Or that he railed against "sodomy" by gays. Or that on the eve of the election, his wife, Kayla Moore, defended him against accusations of anti-Semitism by saying — in remarks written in advance — that "one of our attorneys is a Jew."
Yet Alabama, a state with a painful history of racial strife, not only rejected Moore; it elected a Democrat who once prosecuted Ku Klux Klansmen for the killing of four girls in the 1963 bombing of the 16th Street Baptist Church in Birmingham.
Sometimes a loss is kind of a win.
Moore's election to the Senate would have created a damaging spectacle for the Republican Party.
In addition to withholding financial support from Moore, GOP Senate leaders threatened proceedings to expel him from Congress. The Senate Ethics Committee was preparing to launch an investigation of Moore's alleged sexual misconduct.
Democrats saw the Moore drama as a chance to strengthen their already significant edge among female voters. They also relished the prospect of Moore's provocative brand of religious-right politics on display as they try to regain control of Congress next November.
Moore's absence from the Senate means one less headache for Republicans.
Jones will be up for reelection in 2020, giving him three years to build a record that can sustain Democrats' improbable hold on the Alabama Senate seat.
The #MeToo movement is a potent force in 2018 elections.
Dozens of men in public life have lost their jobs or careers in recent weeks as women have come forward with accusations of sexual harassment.
Three members of Congress resigned just last week.
The allegations against Moore were some of the most serious against anyone in politics — and the first confronted directly by voters amid the upheaval over sexual misconduct by powerful men.
Leigh Corfman, 53, went on national television and told of Moore initiating a sexual encounter with her when she was 14 and he was 32.
They stripped to their underwear, he fondled her breasts and put her hand on his crotch before she put a stop to it, according to Corfman.
Her story, and those of others who accused Moore of sexual misconduct, had a big impact.