Judge Brett Kavanaugh was set to be confirmed as a US supreme court justice on Saturday, handing Donald Trump a major victory after weeks of shocking allegations, rage-fuelled hearings and rancorous protests that have further divided America.

The final vote in the Republican-controlled Senate, which was poised to fall almost entirely along party lines in the afternoon, would confirm Kavanaugh to the lifelong position – and tilt America’s highest court in a conservative direction for decades.

The almost-certain victory will cap a triumphant week for the president. He strong-armed a new trade deal with Canada and Mexico, which the markets loved, marked the lowest unemployment rate in the US since 1969, at just 3.7%, and was on the brink of securing the second ultra-conservative supreme court nomination of his administration, after putting Neil Gorsuch on the bench last year.

Sign up for the US morning briefing

But to many Kavanaugh will be forever tainted by accusations from Christine Blasey Ford, a research psychologist, that he sexually assaulted her when they were teenagers at a high school party, and by doubts over his honesty during intensely emotional and partisan testimony at a Senate judiciary committee hearing, which brought his youthful drinking habits into question.

Hundreds of protesters gathered outside the supreme court building in Washington on Saturday and many were arrested and led down the court steps with their hands in plastic cuffs behind their backs.

The bitter political fight crystallised the polarisation of the Trump era. It also became a cultural litmus test of the year-old #MeToo movement, which inspired women to speak out about incidents of sexual harassment and abuse, as it collided with the patriarchy of a political establishment dominated by ageing white men.

On Friday night all the way through to Saturday morning, Democrats staged a last stand on the Senate floor with a series of speeches opposing the nominee, though the chamber was mostly empty. “Today, in just a few hours, the United States Senate is going to turn its back on righteousness,” Senator Kirsten Gillibrand of New York said. “It’s going to turn its back on fairness and reason. And make no mistake, it is going to turn its back on women.”

Facebook Twitter Pinterest Susan Collins said she would vote to confirm Kavanaugh. Photograph: Erik S. Lesser/EPA

But it was almost certainly in vain after Kavanaugh cleared a key procedural vote on Friday. In that 51-49 result, Senator Lisa Murkowski of Alaska was the lone Republican to oppose his nomination, while Senator Joe Manchin, a Democrat up for re-election in conservative West Virginia, was the only Democrat to break from his party and back the judge.

Thousands of protesters, many of them victims of sexual assault, had flooded the US Capitol in the days leading up to the vote with impassioned pleas to reject Kavanaugh. In scenes of raw, visceral anger, senators were challenged in corridors and lifts and were booed and jeered as they went to vote. There were hundreds of arrests. But two closely watched Republican moderates, Senators Susan Collins of Maine and Jeff Flake of Arizona, ultimately gave Kavanaugh their stamp of approval.

In a 45-minute speech, Collins said she found Ford’s testimony last month describing Kavanaugh’s alleged 1982 drunken assault as “sincere, painful and compelling” but added: “The facts presented do not mean that Professor Ford was not sexually assaulted that night or at some other time, but they do lead me to conclude that the allegations failed to meet the more likely than not standard.”

Collins faced a fierce backlash from activists. Linda Sarsour, co-chair of the Women’s March organisation, said: “Senator Susan Collins is the mother and grandmother of white women in America who gave us a Donald Trump presidency. She is a disgrace, and her legacy will be that she was a traitor to women and marginalised communities. History will not treat her kindly.”

The Senate is going to turn its back on fairness and reason. And make no mistake, it is going to turn its back on women Kirsten Gillibrand

Protesters chanted “Shame in you! Shame on you!” at Manchin when he talked to reporters outside his office.

The tensions over Kavanaugh’s nomination underscored the deep mistrust between the two major parties in Washington, underlining concerns over the nation’s broken politics. Senator John Kennedy described the confirmation process as “an intergalactic freak show”. Senator Chuck Grassley, chairman of the judiciary committee, said the Senate was approaching “rock bottom”.

Republicans claimed that a reopened FBI investigation over the past week had found no evidence to corroborate the accounts of Ford and Deborah Ramirez, a former classmate of Kavanaugh’s who alleged he exposed himself to her while the two attended Yale University. Democrats said the investigation was incomplete and had been curtailed by the White House.

Kavanaugh vehemently denied Ford’s allegations when he testified last month on Capitol Hill, furiously and tearfully claiming a coordinated smear campaign by Democrats. He sought to repair his reputation in an column published late Thursday in the conservative editorial pages of the Wall Street Journal. “I might have been too emotional at times,” he wrote. “I know that my tone was sharp, and I said a few things I should not have said.”

The controversy became one of most explosive and polarising supreme court battles since 1991, when conservative justice Clarence Thomas was confirmed after being accused of sexual harassment by his former employee, Anita Hill. Though there were striking parallels, Ford’s allegation came in an era of increasing political tribalism and against the backdrop of the #MeToo movement.

Play Video 3:24 Key moments from Brett Kavanaugh's confirmation battle – video report

Trump, who has been accused by more than a dozen women of sexual harassment, at first showed signs of restraint in his response to the allegations against his nominee. After Ford testified, he called her a “very fine woman” who offered a “compelling” account. But at a rally in Mississippi days before the vote, he offered a mocking impression of Ford’s testimony before a cheering crowd.

Trump and his allies have turned the saga into a narrative of male victimhood. The president described it as a “scary time for young men in America” who might be falsely accused. Republican Senator Lindsey Graham told a hearing: “I’m a single white male from South Carolina, and I’m told I should just shut up, but I will not shut up.”

Republicans claimed that polls show signs of a “Brett bounce” in next month’s elections for control of Congress, firing up party supporters who might otherwise have not bothered to vote. Kevin McCarthy, the Republican majority leader in the House of Representatives, told Fox News: “Prior to the Kavanaugh hearing, the intensity level was really on the Democratic side. But in the last week there has been a fundamental shift.”

A Facebook executive’s Kavanaugh support is a slap in the face to women | Arwa Mahdawi Read more

Whit Ayres, a Republican pollster, said on Saturday: “It’s certainly not going to hurt Democratic enthusiasm – that’s a safe bet – but Kavanaugh did gin up Republican enthusiasm as well because a lot of Republicans felt a good man was being railroaded unfairly. You are going to have energised voters on both sides.”

Republicans have appeared willing to take short term pain at the ballot box for the prize of shifting the supreme court for a generation. Trump vowed as a candidate to nominate “pro-life” judges in a commitment that helped earn him the support of religious conservatives. His selection of Kavanaugh to replace the retired Anthony Kennedy was hailed as the crowning achievement of a three-decade effort to install a conservative majority on the nation’s highest bench.

A key focal point of the early opposition to his nomination focused on his views on Roe v Wade, the landmark 1973 supreme court decision that affirmed a woman’s constitutional right to an abortion.

Disputes involving abortion, immigration, gay rights, voting rights and transgender troops all could be heading towards the court soon. Kavanaugh could be the decisive vote.

Legal analyst Jeffrey Toobin told CNN: “Abortion, affirmative action, campaign finance, gay rights – all those are going to go in a very different direction because Anthony Kennedy is gone and Brett Kavanaugh will be there.”

• This article was corrected on 8 October 2018. Dr Ford is a research psychologist, not a research psychiatrist.