Donald Trump has responded to Roy Moore's defeat in the Alabama Senate election race. In a tweet the US President congratulated the Democrat Doug Jones, and suggested that write-in votes worked against the Republican candidate, who was accused of child sex abuse during his campaign.

"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 President wrote. "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 Moore has adamantly denied all the allegations against him, made by a number of women. The claims included Mr Moore allegedly making unwanted advances towards a 14-year-old when he was in his 30s. He has said: “I have never engaged in sexual misconduct” and decrying what he called a partisan effort to derail his campaign.

Mr Trump's mention of the write-in votes relates to the fact that the number of such votes is almost equal to Mr Jones margin of victory. Mr Moore and his campaign have said they are not yet conceding the result, with some votes still outstanding.

Alabama state law calls for a recount if the margin of victory is less than one-half of one percentage point. With all precincts reporting, Mr Jones leads by 1.5 percentage points — three times what's required to trigger a recount.

If the Alabama 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.

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

Mr Jones' victory is set to narrow the slim Republican majority over Democrats in the Senate to 51-49.