Doug Jones has become the first Democrat in 25 years to win a US Senate seat for Alabama after a bitter campaign against Republican Roy Moore.
The 63-year-old former prosecutor’s victory deals a blow to Republicans, narrowing their majority to 51-49 in the Senate.
The election took a twist when Mr Moore became embroiled in allegations of sexual misconduct with teenage girls.
Mr Moore, who was backed by President Donald Trump, denies the claims.
Mr Jones is a former lawyer known for helping convict two Ku Klux Klan members who bombed a black church in 1963 in Birmingham, killing four girls.
“This entire race has been about dignity and respect,” he said in his victory speech.
He wins the seat vacated by US Attorney General Jeff Sessions.
Mr Moore, a firebrand conservative who was twice removed from the state Supreme Court, has said that homosexual activity should be illegal and argued against removing segregationist language from the state constitution.
But it was allegations of sexual misconduct made by several women, some when they were teenagers, that drew national attention to the special election.
The claims against Mr Moore came amid a wave of allegations of sexual misconduct against prominent figures that has led to the resignation of three politicians.