WASHINGTON—The Senate confirmed Brett Kavanaugh to the Supreme Court on Saturday, cementing a conservative majority on the nation’s top court after a blistering battle over sexual-assault allegations leveled against him.

Judge Kavanaugh was confirmed by a two-vote margin, with 50 in favor, 48 opposing, and Sen. Lisa Murkowski (R., Alaska) voting present. One senator, Republican Steve Daines of Montana, was absent due to his daughter’s wedding.

Judge Kavanaugh was sworn in late Saturday in a private ceremony at the court. Chief Justice John Roberts administered one of the two required oaths and retired Justice Anthony Kennedy the other, allowing Justice Kavanaugh “to participate in the work of the court immediately,” the court said in a statement.

Judge Kavanaugh’s confirmation will cement a 5-4 conservative majority that has been a top goal of right-leaning activists for decades, while likely fueling the anger of liberals who argue that Republicans improperly blocked former President Obama’s last Supreme Court pick.

The emotions surrounding the confirmation fight show no signs of dissipating with its conclusion. In the Senate chamber, women stood up to scream “Shame” and “Sexual assault survivors vote,” an allusion to the midterms a month away. Outside the Capitol, protesters carried signs that read “Cancel Kavanaugh” and chanted “We vote next.”