A Democrat was just elected as a senator from Alabama. It took the most flawed Senate candidate in recent memory to make it happen.

Doug Jones, making his first run for elected office, defeated former State Supreme Court Chief Justice Roy Moore on Tuesday night, according to the Associated Press, breaking a decades long dry spell for Democrats in the Yellowhammer State. In doing so, Jones delivered a stunning rebuke to the White House and some Republicans who lined up behind the deeply flawed Moore.

Jones, who is best known for his successful prosecution of two KKK members who bombed the 16th St. Baptist Church in Birmingham, spent the closing days campaigning hard in the African-American community. As the election neared, the Jones campaign brought in heavy hitters like Alabama-born basketball player Charles Barkley as well as potential 2020 presidential contenders Sen. Cory Booker (D-NJ) and former Massachusetts Gov. Deval Patrick.

While most national Democrats intentionally stayed away from the race, for fear of branding Jones with the party’s unpopular image in the state, both former President Barack Obama and Vice President Joe Biden—a longtime Jones booster—recorded robocalls in the final days.

At first, Jones seemed like a long shot. A Democrat had not been elected statewide in Alabama since 2008. But after allegations surfaced of Moore’s sexually harassing teenage girls while in his thirties—including one woman who was 14 at the time of Moore’s alleged advances—Jones’ prospects skyrocketed.

More than anyone else, Jones’ win is a blow for Donald Trump. The president had initially endorsed Moore’s primary opponent Sen. Luther Strange (R-AL). And after the allegations against Moore first surfaced, he stayed away from the candidate. But in the eleventh hour, Trump changed his tune, cutting a robocall for Moore and holding a political rally in nearby Florida in which he touted his campaign.

The president insisted that Moore’s vote was vital in moving his agenda. His loss, instead, will reduce the Republican Party’s majority in the Senate to one (51-49). And though GOP leadership seems poised to try and rush a vote on their massive tax cut package before Jones is seated, his vote will have an impact on numerous other legislative items and judicial nominations.