Doug Jones, the man who made his name prosecuting two former Ku Klux Klan members who bombed a black church, has won a stunning victory in the Senate race in Alabama - the first Democrat to win such a seat in the state for 25 years.
In doing so, the 63-year prosecutor, who just weeks ago was trailing Republican Roy Moore by double digits in the polls, also delivered a humiliating blow to Donald Trump, who had mocked Mr Jones and endorsed his opponent. It also reduces the Republican majority in the Senate to 51-49, complicating Mr Trump's efforts to push forward his legislative agenda.
Mr Jones’s fortunes increased sharply after Mr Moore’s campaign was rocked by allegations that he abused teenage girls and women when he was in his thirties and working as a local prosecutor.
Mr Moore denied the allegations and dismissed them as an attempt to undermine his campaign, but they appeared sufficient to either lead some Republicans to vote for Mr Jones or else to enable the Democrat to persuade a sufficient number of his potential supporters to actually go out and cast their ballots for him. However, Mr Moore's campaign made clear in the wake of the result that they were not conceding yet.
It didn't stop Mr Jones and his supporters celebrating the result. He told the victory - indeed the "entire race" - had been "about dignity and respect".
Mr Jones said he now wanted to find “common ground” with other politicians in Washington.
Appearing visibly emotional on stage at a campaign victory rally in the city of Birmingham, he said: “I have always believed that the people of Alabama have more in common than divides us.
“We have shown not just around the state of Alabama, but we have shown the country the way - that we can be unified.”
Celebrating the victory on the same day he marked his 25th wedding anniversary, Mr Jones said he felt overwhelmed by the result.
“Take this election from the great state of Alabama. Take this opportunity,” he said. “On a very personal level, I want to thank each of you for fulfilling a lifelong dream to serve in the US Senate.”
Thank you ALABAMA!!— Doug Jones (@GDouglasJones) December 13, 2017
While raucous celebrations went on long into the night in Birmingham, at Mr Moore's headquarters in Montgomery there was silence after the result became clear.
One of the former judge’s longtime supporters, Rich Hobson, took to the stage to say the Republican was not conceding the race.
“Some people are calling this. We’re not calling it yet,” he said. “In the meantime, I'd ask you to pray."
Mr Moore also came out on stage and said that he would not be conceding, telling campaign supporters “it's not over.”
“It's going to take some time,” the candidate said during a brief appearance before supporters.
Campaign chairman Bill Armistead said that because the vote is close and approaching the state's recount requirement, “we do not have a final decision on the outcome.”
Alabama state law calls for a recount if the margin of victory is less than 0.5 per cent. With all precincts reporting, Mr Jones leads by 1.5 percentage points — three times the threshold.
If the secretary of state determines there were more write-in votes than the difference between Mr Jones and Mr Moore, the state's counties would be required to tally those votes. It's not clear how that would help Mr Moore, who ended the night trailing Mr Jones by more than 20,000 votes.
Once again, it means President Trump has thrown his weight behind a candidate in Alabama - and lost. On Tuesday morning, hours after ballots opened, Mr Trump had repeated his support for Mr Moore on Twitter, where he has 45 million followers.
“The people of Alabama will do the right thing,” he said. “Doug Jones is pro-abortion, weak on crime, military and illegal immigration, bad for gun owners and veterans and against the wall. Jones is a Pelosi/Schumer Puppet. Roy Moore will always vote with us.”
On Tuesday night, as news of Mr Jones' stunning upset sank in, not just among the political class but across the country, Mr Trump offered measured congratulations.
"Congratulations to Doug Jones on a hard fought victory. The write-in votes played a very big factor, but a win is a win. The people of Alabama are great, and the Republicans will have another shot at this seat in a very short period of time. It never ends," he said.
If the result was a huge embarrassment for the President it was a similar blow for his former strategist, Steve Bannon, who had become one of Mr Moore’s most outspoken supporters and who was hoping to use what he believed would be a victory in Alabama, to drive the momentum for similar so-called insurgent campaigns in 2018.
"To all the little girls watching...never doubt that you are valuable and powerful & deserving of every chance & opportunity in the world."— Hillary Clinton (@HillaryClinton) November 9, 2016
Mr Bannon had been scornful of Mitch McConnell and other senior Republicans in Washington, who he claimed were working against Mr Trump. It was Mr Bannon those senior Republicans blamed for the result in one of the country’s most conservative states.
Steven Law, CEO of the Senate Leadership Fund, a political fundraising group closely linked to Mr McConnell, the Senate Majority Leader, issues a damning statement: “This is a brutal reminder that candidate quality matters regardless of where you are running.
“Not only did Steve Bannon cost us a critical Senate seat in one of the most Republican states in the country, but he also dragged the President of the United States into his fiasco.”
Hillary Clinton, who was beaten 62-34 in Alabama by Mr Trump in the 2016 presidential election, was among the first to congratulate Mr Jones.
“Tonight, Alabama voters elected a senator who'll make them proud,” she tweeted.
“And if Democrats can win in Alabama, we can — and must — compete everywhere. Onward!”