(BBC) — The US Senate has voted to confirm President Donald Trump’s nominee for the Supreme Court, after weeks of rancorous debate.
The Senate backed Brett Kavanaugh’s nomination by 50 votes to 48.
Mr Kavanaugh had been embroiled in a bitter battle to stave off allegations of sexual assault.
But after an 11th-hour investigation by the FBI into the allegations, enough wavering senators decided to back the nomination.
Ahead of the vote, hundreds of people protested against Mr Kavanaugh’s nomination at the US Capitol in Washington.
During the vote, other protesters shouted “shame” from the public gallery and Vice-President Mike Pence had to call for order to be restored.
Mr Kavanaugh’s appointment is for life and he will strengthen conservative control of the nine-judge court, which has the final say on US law.
The 53 year old will be sworn in later on Saturday at the Supreme Court. Protesters have gathered there too to continue the demonstrations.
What has Mr Trump said?
He sent out a tweet of congratulations:
Later he spoke to reporters aboard Air Force One, saying Mr Kavanaugh had withstood a “horrible attack by the Democrats” and that women were “outraged” at what had happened to the nominee.
Mr Trump also said he was “100% certain” that the woman who had accused Mr Kavanaugh of sexual assault, Christine Blasey Ford, had named the wrong person.
So what were the numbers in the Senate?
The upper house is split 51-49 in favour of the Republicans and the vote was largely along party lines. In the end, there was indeed a two-vote margin, the closest nomination vote since 1881.
The only party dissenters were Republican Senator Lisa Murkowski, who had intended to vote no, and Democrat Joe Manchin, who voted yes.
That should have meant a 51-49 tally, but the absence of Republican Steve Daines, a yes voter who was at his daughter’s wedding, altered the final figures.
Ms Murkowski opted instead to simply mark herself as “present”, leaving the final vote 50-48.
What was said in the Senate?
In their final summations, the two Senate party leaders reflected how bitter the divide had become.
Minority Democrat leader Chuck Schumer said Mr Kavanaugh did not belong on the bench as he had “obscured his views to the American people”, “repeatedly misled the Senate” and delivered one of the “bitterest and most partisan testimonies ever presented by a nominee”.
He also said Mr Trump had “stooped to new depths” in mocking the testimony of Christine Blasey Ford.
Mr Schumer said that for all those who opposed the nomination, “there is one answer – vote” in the November mid-term elections.
Majority Republican leader Mitch McConnell said Mr Kavanaugh was a “serious scholar, a brilliant student of the law and a meticulous and dedicated public servant”.
He said events had “strained our basic principles of fairness and justice” and that the vote showed the Senate was “an institution where evidence and facts matter”.
He spoke of “intimidation by the mob” and said the Senate vote should be one “to turn away from darkness”.
Ms Murkowski had earlier said that although Mr Kavanaugh was a “good man”, he was “not the right person for the court at this time” and his “appearance of impropriety has become unavoidable”.
Joe Manchin is facing a difficult re-election campaign in West Virginia, a traditionally Republican state that Mr Trump won by a landslide. He said he “found Judge Kavanaugh to be a qualified jurist”.
There were shouts of “shame” from the public gallery as he voted yes.
Two Republican waverers, Susan Collins and Jeff Flake, finally decided to back the judge.
Analysis: Just the beginning
By Anthony Zurcher, BBC North America reporter
Brett Kavanaugh’s confirmation to the Supreme Court has been decided. The political war, however, is just beginning.
Donald Trump’s court pick generated a controversy that captured the nation’s attention in a way that few political issues do. It generated daily headlines rivalled only by the US quadrennial presidential elections.
Now that the bombs have been thrown, it’s time to assess the fallout.
Why is the court so important?
Basically, it’s the final arbiter of US law.
It has the ultimate say on such contentious issues as abortion and gun control.
The Democrats are still smarting from the previous Supreme Court appointment. Republicans last year successfully stalled the process, meaning it fell to Mr Trump, not Barack Obama, to nominate the new justice. Mr Trump’s choice of Neil Gorsuch strengthened the conservative leaning.
All eyes will now be on November’s mid-term elections. Mr Trump will be able to campaign on the back of an important victory, but commentators will be watching closely how the Kavanaugh affair affects women voters.