Republican Cindy Hyde-Smith has won Mississippi’s racially charged Senate election, beating a challenge from the black Democrat, Mike Espy.
It extends the Senate majority of President Donald Trump’s party to 53, compared with the Democrats’ 47.
The race narrowed after Ms Hyde-Smith, who is white, was recorded saying she would happily attend a public hanging.
The comments evoked the lynching of African-Americans in a state scarred by a history of racial violence.
With nearly all votes counted, Ms Hyde-Smith had taken 54.4% of the vote compared to 45.6% for Mr Espy.
President Trump tweeted his congratulations.
In a statement, Ms Hyde-Smith said: “I want everybody to know, no matter who you voted for today, I am going to represent every Mississippian.”
Conceding to his opponent, Mr Espy tweeted that he was “proud of the historic campaign we ran and grateful for the support”.
The runoff election campaign had dredged up aspects of the Deep South state’s ugly past.
On Monday, several nooses were found at the Mississippi capitol in Jackson in an apparent protest against the tenor of the campaign.
Signs alongside the ropes urged voters to elect “someone who respects the lives of lynch victims” and “remind people that times haven’t changed”, according to local media.
This election became more competitive after a video emerged earlier this month of Ms Hyde-Smith – who is the incumbent senator – saying she would be “on the front row” if one of her supporters “invited me to a public hanging”.
For many, the comment evoked past lynchings of African-Americans.
According to the National Association for the Advancement of Colored People (NAACP), Mississippi had the highest number of lynchings in the nation from 1882 to 1968.
Mr Espy condemned his rival’s comment as “reprehensible”; Ms Hyde-Smith maintained there was no “negative connotation”.
The Democrat has himself come under scrutiny for his 2011 lobbying work in the Ivory Coast, whose former despot Laurent Gbagbo is on trial at the International Criminal Court.
Mr Espy was agriculture secretary under President Bill Clinton, but resigned under a cloud of corruption allegations, on which he was later acquitted.
Ms Hyde-Smith, meanwhile, was further criticised when photos surfaced of her posing at the home of Confederate President Jefferson Davis, with the caption: “Mississippi history at its best.”
A video of Ms Hyde-Smith – who was the first ever US congresswoman from Mississippi – apparently encouraging voter suppression also emerged on Twitter.
That recording showed the senator saying there were some liberals “who maybe we don’t want to vote – maybe we want to make it just a little more difficult [to vote]”.
Her campaign later said the comment was a joke and the video had been “selectively altered”, the Washington Post reported.
At a recent debate, Ms Hyde-Smith gave a qualified apology to anyone she had offended, while adding that opponents had “twisted” her words “as a political weapon”.
President Donald Trump travelled to Mississippi on the eve of the vote to campaign for Ms Hyde-Smith.
“I know her, and I know she apologised, and she misspoke,” the Republican president told reporters on his way to the state.
He painted Mr Espy as a far-left ideologue who would “rather protect illegal aliens than people who live in Mississippi”, and questioned how he “fit in with Mississippi”.
Mr Espy’s campaign had pushed the idea that electing Ms Hyde-Smith would stoke a lingering view of Mississippi as a racist southern state.
“We can’t afford a senator who embarrasses us and reinforces the stereotypes we’ve worked so hard to overcome,” one ad for the Democrat said.
Mr Espy needed to overwhelmingly win the black vote and a substantial number of white voters to unseat his Republican opponent.
Why was the election still unresolved?
After Republican Senator Thad Cochran resigned in April, a special election for Mississippi’s US Senate seat was arranged.
Under the state’s law, if no candidate wins over 50% of the votes, a runoff election must take place.
On 6 November during the mid-term elections, both Ms Hyde-Smith and Mr Espy received about 41% of the vote.