Kevin McCarthy has been elected Speaker of the US House of Representatives amid heated exchanges which almost saw fellow Republicans come to blows.
It took 15 rounds of voting for Mr McCarthy to win the job, despite his party having a majority in the chamber.
It came after a dramatic pressure campaign played out live on the House floor as party rebel Matt Gaetz was urged to vote for Mr McCarthy.
The Florida Congressman was among six holdouts who relented late on Friday.
Earlier, amid heated scenes in the chamber, Mr Gaetz had almost come to blows with Rep Mike Rogers – a supporter of Mr McCarthy. The Alabama congressman had to be physically restrained by colleagues as he bellowed and jabbed his finger at Mr Gaetz.
The Speaker sets the House agenda and oversees legislative business. The post is second in line to the presidency after the US vice-president.
Speaking after his confirmation, Mr McCarthy wrote on Twitter: “I hope one thing is clear after this week: I will never give up. And I will never give up for you, the American people.”
US President Joe Biden congratulated Mr McCarthy for his win and said he looked forward to co-operating with the Republican Party.
“The American people expect their leaders to govern in a way that puts their needs above all else, and that is what we need to do now,” he said.
Republicans have already pledged to launch investigations into Mr Biden’s family business dealings and administration.
In a remarkable turnaround in the 12th round of voting, Mr McCarthy was able to persuade 14 Republican holdouts to cast their vote for him. A 15th rebel followed suit for the 13th ballot.
After the 13th ballot was adjourned, Mr McCarthy insisted to reporters that he would “have the votes” to take the speakership on the next round.
What has Kevin McCarthy given up, and at what price?
These are the six rebels blocking Kevin McCarthy
Republican voters weigh in on US House Speaker gridlock
But the California congressman was still three votes short of the 217 he needed to take the prized gavel, and in chaotic and dramatic scenes, he again failed to win on the 14th ballot.
The dissidents included members of the House Freedom Caucus, who argue that Mr McCarthy is not conservative enough to lead them as they work to try to oppose Democratic President Joe Biden’s agenda.
Mr McCarthy has offered various concessions to the rebels, including a seat on the influential rules committee, which sets the terms for debate on legislation in the chamber.
He also agreed to lower the threshold for triggering a vote on whether to unseat the Speaker, to only one House member, leading to the possibility that the Republican coalition could easily fracture again even after Mr McCarthy’s victory.
As the last politician on the roll – Montana’s Ryan Zinke – voted, the House floor erupted in applause as it became clear Mr McCarthy had finally emerged victorious
Mr McCarthy hugged other representatives and signed autographs, but across the room the Democrats’ side was completely silent. No democrat applauded.
Senior Democratic Party lawmakers accused Mr McCarthy of ceding power to an extreme wing of his party and likened the stand-off to the riot exactly two years ago on Capitol Hill by Trump supporters who disrupted Mr Biden’s certification as president.
“Two years ago insurrectionists failed to take over the Capitol,” Congressman Eric Swalwell wrote on Twitter. “Tonight Kevin McCarthy let them take over the Republican Party.”
And Virginia Congressman Don Beyer referred to the angry scenes among Republicans that followed the 14th count.
“Unsettling that this process ends in threats of violence in the House Chamber, on this of all days,” he said. “Maybe it didn’t determine the outcome, but that is no way to conduct the people’s business. A dark and sobering moment will probably be remembered long after this session ends.”
The minority Democrats had continued to vote in unison for their leader, New York’s Hakeem Jeffries, the first black person ever to lead a party in Congress.
Friday was the first day that Mr McCarthy’s vote count actually surpassed that of Mr Jeffries.
Mr McCarthy opened his acceptance speech joking; “that was easy, eh?”. He outlined a range of Republican policy objectives that included lowering prices, securing the US-Mexico border and combatting what he described as a “woke indoctrination”.
He said one of his primary goals was to stop “wasteful Washington spending”.
The lawmakers began leaving the Congress around 02:00 local time (07:00 GMT) on Saturday morning – 14 hours after the gavel first rang at noon.
Not since 1860 in the build-up to the American Civil War has the lower chamber of Congress voted this many times to pick a speaker. Back then it took 44 rounds of ballots.
In November’s midterm elections, Republicans won the House by a weaker-than-expected margin of 222 to 212. Democrats retained control of the Senate.