Democrat Doug Jones has won the US Senate race in Alabama in a blow to Donald Trump, projections suggest.
The former prosecutor's victory comes in the traditionally conservative state against Republican Roy Moore, a candidate backed by the US President even after facing allegations of sexual misconduct.
The 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 to him 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.
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!"
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) 13 December 2017
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."
Mr Trump's election rival Hilary Clinton soon tweeted her congratulations to Mr Jones.
She said: "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!"
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.
More from Donald Trump
The Republican said votes were still coming in and that state law would allow a recount if the margin was within half a percent.
During a brief appearance at a campaign party, he said: "It's not over. We know that God is still in control."