Projections suggest Democrat Doug Jones has won the US Senate race in Alabama in what is seen as a blow to the country’s President Donald Trump.
The former prosecutor's victory makes him the first Democrat elected to the US senate from Alabama in 25 years.
President Trump was backing Republican Roy Moore – despite the allegations of sexual misconduct he was forced to deny.
Republicans still maintain control of both houses of Congress but Mr Jones' victory will reduce their majority in the US Senate to 51-49, which could make it harder for President Trump to push through his policy agenda.
Mr Jones, 63, becomes the first Democrat elected to the US Senate from Alabama in 25 years and opens the doors for his party to possibly retake the chamber in congressional elections next year.
His rival denied the sexual allegations against him despite opposition from within the Republican Party in the lead up to the vote.
Senate Republican leader Mitch McConnell had called on the 70-year-old to drop out of the race.
But Mr Trump endorsed his party's candidate and held a campaign rally across the border in Florida last week. He also tweeted: "Roy Moore will always vote with us. VOTE ROY MOORE!"
According to network exit polls, the US leader was not a factor for about half of voters after 29% said they voted in support of the President and 20% said they voted to oppose him.
Mr Trump has since tweeted, congratulating Mr Jones for his victory.
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
He 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!"
President Donald Trump points out an embattled Alabama Republican Senate candidate Roy Moore supporter as he speaks at a campaign-style rally in Pensacola, Florida, 08-12-2017. Image: Susan Walsh/AP/Press Association Images
The response comes after Mr Jones thanked his family and colleagues as he addressed cheering supporters.
He said: "I think that I have been waiting all my life and now I just don't know what the hell to say."
He added: "I am truly, truly overwhelmed but you know folks, you all heard me say this at one point or another in this campaign, I have always believed that the people of Alabama had more in common than to divide us."
However, Roy Moore's campaign team had said it was unwilling to concede the Alabama election to Mr Jones despite him having a 1.5% lead after 99% of vote had been counted.
The Republican said votes were still coming in and that state law would allow a recount if the margin was within half a percent.