Democratic candidate Doug Jones has won the special Senate election in Alabama in a major blow to US president Donald Trump, who backed Republican candidate Roy Moore.

Mr Jones, a 63-year old Alabama lawyer, defied expectations by winning the seat vacated by attorney general Jeff Sessions – becoming the first Democrat to win a Senate seat in Alabama in more than a quarter of a century.

His victory was widely seen as a reflection on the Trump presidency, which backed Mr Moore, a former judge who had been accused of initiating sexual activity with teenagers by more than a dozen women.

While the Republican establishment – including Senate majority leader Mitch McConnell and Alabama’s senior senator Richard Shelby – had urged voters not to vote for Mr Moore, Mr Trump had backed the firebrand candidate in the final stages of the campaign, despite mounting controversy over his alleged sexual activity with underage women when he was in his 30s.

The Democratic victory in the staunchly Republican state has prompted fears among Republicans about the effect of the Trump presidency among the electorate ahead of next year’s midterm elections.

A better than expected turnout by African American voters and in urban areas appeared to offset Mr Moore’s support in rural areas of the state, which has a high proportion of evangelical voters.

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! — Donald J. Trump (@realDonaldTrump) December 13, 2017 Tonight, Alabama voters elected a senator who'll make them proud.



And if Democrats can win in Alabama, we can -- and must -- compete everywhere.



Onward! — Hillary Clinton (@HillaryClinton) December 13, 2017 Thank you ALABAMA!! — Doug Jones (@GDouglasJones) December 13, 2017

With 99 per cent of the votes counted, Doug Jones had won 49.9 per cent of the vote, with Roy Moore on 48.4 per cent. Addressing supporters, Mr Moore indicated that he was unwilling to concede. “I really want to thank you for coming tonight and realise when the vote is this close that it’s not over,” he said, adding: “God is always in control. You know ... part of the problem with this campaign is we’ve been painted in an unfavourable and unfaithful light.”

But Alabama’s secretary of state, John Merrill. said it was “highly unlikely” that Mr Jones would not be elected senator.

Mr Jones praised supporters at a rally in Birmingham. Recalling that Alabama had “previously been at a crossroads,” he said that “unfortunately we usually took the wrong fork – tonight, ladies and gentleman, you took the right road”.

The Senate campaign had been about “the rule of law ... about common courtesy and decency”, he said.

Misconduct allegations

The race to fill the seat vacated by Jeff Sessions when he was appointed by attorney general by Mr Trump in January has been beset by controversy, after Mr Moore was accused of sexual misconduct by several women who alleged the former judge had initated sexual conduct with them while they were teenagers.

Mr Moore had previously risen to national prominence for his ultra-conservative views. He was twice dismissed from his position as chief justice on the Alabama supreme court for directing federal judges to not recognise the US supreme court ruling allowing same-sex marriage, and for erecting a giant tablet inscribed with the Ten Commandments outside his courthouse.

In a tweet on Tuesday night as the results emerged, Mr Trump wrote: “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!”

Mr Jones’s victory has given newfound optimism to Democrats hoping to regain control of Congress in next year’s midterm elections. Defeated presidential candidate Hillary Clinton tweeted: “Tonight, Alabama voters elected a senator who’ll make them proud. And if Democrats can win in Alabama, we can – and must – compete everywhere,” she said on Twitter.

Mr Jones’s victory also diminishes the Republican Party’s control of the senate. They will now control 51 seats of the 100-member chamber, down from a majority of 52-48.