With Mr Jones’s opponent still refusing to concede victory, Republicans quickly plunged their knives into Steve Bannon, Donald Trump’s former strategist and the conservative impresario, who believed former judge Roy Moore would kick-start his anti-establishment operation for the 2018 mid-term elections.

Mr Trump, who had eventually endorsed Mr Moore, despite the allegations of sexual abuse levelled at him – accusations Mr Moore denies – was forced to offer congratulations of sorts to the 63-year-old Democrat.

But he followed his grudging words with a subsequent tweet in which he sought to distance himself from Mr Moore’s calamity.

“The reason I originally endorsed Luther Strange (and his numbers went up mightily), is that I said Roy Moore will not be able to win the General Election,” he said. “I was right. Roy worked hard but the deck was stacked against him.”

Speaking from the White House later, Mr Trump said: "Wish we would have gotten the seat. A lot of Republicans feel differently, they’re happy very with the way it turned out, but I would have as the leader of the party, I would have liked to have had the seat".

One of those Republicans was Bob Corker, a frequent critic of Mr Trump who is retiring next year.

"I know we're supposed to cheer for our side of the aisle ... but I'm really, really happy with what happened for all of us in our nation, for people serving in the Senate, to not have to deal with what we were likely going to have to deal with should the outcome have been the other way," Mr Corker said.

As for Mr Bannon, critics were quick to offer harsh judgement.

"This guy does not belong on the national stage," Republican Representative Peter King said on CNN. "He's not representing what I stand for. I consider myself a conservative Republican... And, to me, it's demeaning the whole governmental and political process."

The race between Mr Moore and Mr Jones, a prosecutor who had made his name as the man who prosecuted two former Ku Klux Klan members who bombed a black church in 1963 and killed four little girls, was closer than any had expected.

Before the flurry of accusations from a number of women alleged that Mr Moore had assaulted them when they were young girls while he was in his thirties and working as a local prosecutor, Mr Moore was leading the Democrat by a double-digit lead in the polls.

After the claims were published, his numbers started to slip as senior Republicans moved to distance themselves from him. The other sitting Republican senator for Alabama, Richard Shelby, said he could not vote for Mr Moore and would instead “write in” the name of another Republican on his ballot paper.

Alabama senate race: Charles Barkley tells Alabama to vote for Doug Jones and 'stop looking like idiots to the nation'

It also energised Mr Jones’s campaign, who worked to reach out to African American voters, younger people and women. He told them they are on the right side of history and on the eve of the election, he told The Independent he believed he could “pull it off” on Tuesday.

He did just that. Shortly before 9.30pm local time on Tuesday evening, first Fox News, quickly followed by the Associated Press and The Washington Post called the race for Mr Jones. A final tally of votes showed Mr Jones had won 671,151 votes to Mr Moore’s 650,436, giving the Democrat a 49.9-48.4 victory.

The reporter from The Washington Post, whose newspaper had broken the allegations of sexual assault against Mr Moore, was refused press credentials for the election night rally even though journalists were being allowed in without their passes being checked.

Speaking in Birmingham, Mr Jones thanked his supporters and reminded them he was also celebrating his 25th wedding anniversary. At the same time, supporters of Mr Moore were praying and singing religious songs in the hall they had hired in Montgomery, expecting to be celebrating a win.

Alabama Senate race: Roy Moore vs Doug Jones Show all 12 1 /12 Alabama Senate race: Roy Moore vs Doug Jones Alabama Senate race: Roy Moore vs Doug Jones Democratic senatorial candidate Doug Jones speaks to reporters after voting Getty Images Alabama Senate race: Roy Moore vs Doug Jones Republican Senatorial candidate Roy Moore (L) and his wife Kayla ride their horses to the polling station to vote AFP/Getty Images Alabama Senate race: Roy Moore vs Doug Jones David Watson waves in a Santa suit as he holds a Doug Jones sign AP Alabama Senate race: Roy Moore vs Doug Jones Republican Senatorial candidate Roy Moore speaks to the media as his wife Kayla (R) looks on AFP/Getty Images Alabama Senate race: Roy Moore vs Doug Jones Democratic Alabama Senate candidate Doug Jones casts his vote at Brookwood Baptist Church REUTERS Alabama Senate race: Roy Moore vs Doug Jones Roy Moore speaks to the media after he rode in on a horse to vote AP Alabama Senate race: Roy Moore vs Doug Jones Democratic candidate Doug Jones greets supporters after casting his ballot AP Alabama Senate race: Roy Moore vs Doug Jones Republican Senate candidate Roy Moore departs on horseback after he cast his ballot in Gallant REUTERS Alabama Senate race: Roy Moore vs Doug Jones Voters wait in line to cast their ballot at a polling station setup in the St Thomas Episcopal Church Getty Images Alabama Senate race: Roy Moore vs Doug Jones Democratic Senatorial candidate Doug Jones (L) greets voters outside of a polling station at the Bessemer Civic Center Getty Images Alabama Senate race: Roy Moore vs Doug Jones Voters exit after casting their ballots at a polling station setup in the Fire Department Getty Images Alabama Senate race: Roy Moore vs Doug Jones Democratic Alabama U.S. Senate candidate Doug Jones speaks with the media after casting his vote at Brookwood Baptist Church Reuters

A key part of Mr Jones’s victory appears to have been the turnout of African American women. Exit poll data suggests they made up 18 per cent of the vote and approximately 97 per cent of their support went to Mr Jones. This compared to 65 per cent of white women – who made up 30 per cent of voters – opting for Mr Moore.

“I have always believed that the people of Alabama have more in common than divides us,” Mr Jones told supporters. “We have shown not just around the state of Alabama, but we have shown the country the way – that we can be unified.”

He added: “This entire race has been about dignity and respect.”

Mr Jones’s win will undoubtedly give heart to Democrats and critics of Mr Trump. Earlier this year, they were hoping another special election, in Georgia’s 6th district, would provide them with a win and some much-needed momentum.

Mr Moore asked people to pray to God and come back in the morning (Getty)

As it was, despite a media frenzy, Jon Ossoff failed to beat Republican Karen Handel. The Democrat was a victim, perhaps, of too much expectation.

Hillary Clinton was quick to congratulate Mr Jones and said his victory showed Democrats could win anywhere. But it may not be that simple; not every candidate the Democrats will be facing in 2018 will be confronting accusations of sexual assault.

Most observers believed that had it not been for those revelations, Mr Moore, a staunch religious conservative whose base of supporters is among the 49 per cent of adults in Alabama who identify as evangelical Christians, would have won.

As it was, Mr Jones’s supporters had the opportunity to dance and sing and take in the pleasures of a most unexpected victory.

“I honestly did not know that this was even an option. I didn’t think that we could elect a Democrat,” 26-year-old campaign volunteer Jess Eddington, her eyes red, told Reuters. “I am so proud we did.”

Elsewhere Democrats were quick to seize on the win.