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...