WASHINGTON (AP) — The bitterly polarized U.S. Senate narrowly confirmed Brett Kavanaugh on Saturday to join the Supreme Court, delivering an election-season triumph to President Donald Trump that could swing the court rightward for a generation after a battle that rubbed raw the country's cultural, gender and political divides.

The near party-line vote was 50-48, capping a fight that seized the national conversation after claims emerged that Kavanaugh had sexually assaulted women three decades ago — which he emphatically denied. Those allegations magnified the clash from a routine Supreme Court struggle over judicial ideology into an angrier, more complex jumble of questions about victims' rights, the presumption of innocence and personal attacks on nominees.

Acrimonious to the end, the battle featured a climactic roll call that was interrupted several times by protesters in the Senate Gallery before Capitol Police removed them. Vice President Mike Pence presided over the roll call, his potential tie-breaking vote unnecessary.

The vote gave Trump his second appointee to the court, tilting it further to the right and pleasing conservative voters who might have revolted against GOP leaders had Kavanaugh's nomination flopped. Democrats hope that the roll call, exactly a month from elections in which House and Senate control are in play, will prompt infuriated women and liberals to stream to the polls to oust Republicans.

In final remarks just before the voting, Senate Republican leader Mitch McConnell of Kentucky said a vote for Kavanaugh was "a vote to end this brief, dark chapter in the Senate's history and turn the page toward a brighter tomorrow."

Democratic leader Chuck Schumer of New York looked ahead to November, appealing to voters beyond the Senate chamber: "Change must come from where change in America always begins: the ballot box."

Rep. Joe Manchin of West Virginia, confronting a tough re-election race next month in a state that Trump won in 2016 by a landslide, was the sole Democrat to vote against Kavanaugh. Every voting Republican backed the 53-year-old conservative judge.

Alaska's Lisa Murkowski, the only Republican to oppose the nominee, voted "present," offsetting the absence of Kavanaugh supporter Steve Daines of Montana, who was attending his daughter's wedding. That rare procedural maneuver left Kavanaugh with the same two-vote margin he'd have had if Murkowski and Daines had both voted.

Republicans hold only a 51-49 Senate majority and therefore had little support to spare.

It was the closest roll call to confirm a justice since 1881, when Stanley Matthews was approved by 24-23, according to Senate records.

Within minutes, dozens of political and advocacy groups blasted out emailed reactions.

Stephanie Schriock, president of EMILY's List, which contributes to female Democratic candidates, assailed the confirmation of "an alleged sexual assailant and anti-choice radical to a lifetime appointment on the Supreme Court. But we will carry that anger into the election. Women will not forget this."

Kay Coles James, president of the conservative Heritage Foundation, called the vote "a victory for liberty in America" and called Kavanaugh "a good man and good jurist."

The outcome, telegraphed Friday when the final undeclared senators revealed their views, was devoid of the shocks that had come almost daily since Christine Blasey Ford said last month that an inebriated Kavanaugh tried to rape her at a 1982 high school get-together.

Since then, the country watched agape as one electric moment after another gushed forth. These included the emergence of two other accusers; an unforgettable Senate Judiciary Committee hearing at which a composed Ford and a seething Kavanaugh told their diametrically opposed stories, and a truncated FBI investigation that the agency said showed no corroborating evidence and Democrats lambasted as a White House-shackled farce.

All the while, crowds of demonstrators — mostly Kavanaugh opponents — ricocheted around the Capitol's grounds and hallways, raising tensions, chanting slogans, interrupting lawmakers' debates, confronting senators and often getting arrested.

Trump weighed in Saturday morning on behalf of the man he nominated in July. "Big day for America!" he tweeted.

Democrats said Kavanaugh would push the court too far, including possible sympathetic rulings for Trump should the president encounter legal problems from the special counsel's investigations into Russian connections with his 2016 presidential campaign. And they said Kavanaugh's record and fuming testimony at a now-famous Senate Judiciary Committee hearing showed he lacked the fairness, temperament and even honesty to become a justice.

But the fight was defined by the sexual assault accusations. And it was fought against the backdrop of the #MeToo movement and Trump's unyielding support of his nominee and occasional mocking of Kavanaugh's accusers.

About 100 anti-Kavanaugh protesters climbed the Capitol's East Steps as the vote approached, pumping fists and waving signs. U.S. Capitol Police began arresting some of them. Hundreds of other demonstrators watched from behind barricades. Protesters have roamed Capitol Hill corridors and grounds daily, chanting, "November is coming," ''Vote them out" and "We believe survivors."

On Friday, in the moment that made clear Kavanaugh would prevail, Collins delivered a speech saying that Ford's Judiciary Committee telling of the alleged 1982 assault was "sincere, painful and compelling." But she also said the FBI had found no corroborating evidence from witnesses whose names Ford had provided.

"We must always remember that it is when passions are most inflamed that fairness is most in jeopardy," said Collins, perhaps the chamber's most moderate Republican.

Manchin used an emailed statement to announce his support for Kavanaugh moments after Collins finished talking. Manchin, the only Democrat supporting the nominee, faces a competitive re-election race next month in a state Trump carried in 2016 by 42 percentage points.

Manchin expressed empathy for sexual assault victims. But he said that after factoring in the FBI report, "I have found Judge Kavanaugh to be a qualified jurist who will follow the Constitution."

Sen. Jeff Flake, R-Ariz., who has repeatedly battled with Trump and will retire in January, said he, too, planned to vote for Kavanaugh's confirmation.

In the procedural vote Friday that handed Republicans their crucial initial victory, senators voted 51-49 to limit debate, defeating Democratic efforts to scuttle the nomination with endless delays.

When Trump nominated Kavanaugh in July, Democrats leapt to oppose him, saying that past statements and opinions showed he'd be a threat to the Roe v. Wade case that assured the right to abortion. They said he also seemed too ready to rule for Trump in a possible federal court case against the president.

Yet Kavanaugh's path to confirmation seemed unfettered until Ford and two other women emerged with sexual misconduct allegations from the 1980s.

Kavanaugh would replace the retired Justice Anthony Kennedy, who was a swing vote on issues such as abortion, campaign finance and same-sex marriage.

___

Associated Press writers Mary Clare Jalonick, Matthew Daly, Padmananda Rama, Ken Thomas and Catherine Lucey contributed to this report.

Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.