(Bloomberg) -- Republican Kevin McCarthy achieved his long-held ambition of becoming House speaker early Saturday after quelling a rebellion by GOP conservative hardliners, but at the cost of further weakening his precarious position within a sharply divided party. 

After the longest series of speaker ballots since 1859, McCarthy had 216 votes in the final tally, enough to be elected to the post that is second in line for the presidency, with six of the dissidents voting “present.” Democrats unanimously cast votes for their leader, New York Representative Hakeem Jeffries.

“Now, the hard work begins,” McCarthy said in his first address to the House as speaker. He ran through the broad strokes of his agenda, including strengthening the southern US border, addressing federal debt, confronting the rise of China and investigating the Biden administration. “We will use the power of the purse, and the power of the subpoena, to get the job done,” he said.

The protracted deadlock between establishment Republicans and hard-line conservatives took 15 votes over more than four days to resolve. And it previews more chaos ahead over the political challenges that will come up this year, including raising the US debt ceiling and funding the government.

The final vote was preceded by dramatic moments on the House floor as the Republican dispute escalated to shouting and physical confrontations. After McCarthy was blocked on the 14th ballot, a stunning and humiliating defeat, he walked quickly to the back of the chamber and confronted Florida’s Matt Gaetz, one of his most strident critics.

Gaetz had held out casting his vote until the very last moment, when it would be decisive. He then voted “present,” which left McCarthy just short of victory. 

As McCarthy was walking back, appearing flustered, one of his allies, Mike Rogers of Alabama stormed over to Gaetz and lunged at him. Rogers was restrained by Representative Richard Hudson of North Carolina as a stunned House watched it unfold. 

The final lobbying included intervention by former President Donald Trump. After McCarthy came up one vote short on the 14th ballot, Trump talked to at least two of the dissidents, Gaetz and Representative Andy Biggs of Arizona, and asked them to help secure victory that night, said a person familiar with the discussion.

A photographer also snapped a picture of Representative Marjorie Taylor Greene, who backed McCarthy, holding out her phone to GOP dissident Matt Rosendale  with “DT” on the line, apparently referring to Trump.

At a press conference afterward, McCarthy thanked Trump for helping him get the final votes. “Nobody should doubt his influence,” he said.

Until the speaker was elected, the House could conduct no other business and there were no rules governing the day-to-day operations of the 434 House lawmakers and their staffs. After Saturday morning’s vote, returning and newly elected lawmakers were finally sworn in. 

McCarthy, a California Republican, prevailed after days of intense negotiations and a series of embarrassing losses. He had to surrender considerable authority, promising to back procedural changes empowering dissidents, including the ability to let a single Republican force a House vote to oust him as speaker. 

He also gave in to demands from fiscal conservatives to use the federal debt ceiling as a bargaining chip to force spending cuts and to cap fiscal year 2024 spending across the government at 2022 levels, which would mean significant cuts to many programs. Both heighten the risk of a market—rattling showdown with the Democratic-controlled Senate and President Joe Biden.

McCarthy told reporters at the press conference that he was “a thousand percent” certain that he’d have the job for the full two year term.

His bid for the speaker’s gavel had been in trouble since the November elections, in which Republicans fell well short of expectations of a so-called red wave that would give them solid majorities in both the House and Senate. 

They won the House, but it’s there that the struggle over the direction of a party is playing out most vividly. Republicans are divided between members from swing districts who have to court independent voters and hard-line conservatives with safe seats who’ve adopted Trump’s populist agenda.

The tide started to turn in favor of McCarthy once he and dissidents hammered out the contours of the deal, with 15 of the holdouts switching their votes to support him during the 12th voting round earlier Friday.

McCarthy, who was first elected in 2012, had said he anticipated the slection going to multiple rounds as a faction of ultra-conservatives pressed their demands for more power. He vowed he wouldn’t back down. 

“I don’t have a problem getting a record for the most votes for speaker,” he said before balloting began.

He had to wait for two of his supporters to return to the Capitol to vote on Friday. Incoming Representative Wesley Hunt of Texas was away to meet his newborn child and Representative Ken Buck of Colorado left Thursday because of a medical matter.

This is the second time McCarthy has hit obstacles in a quest for the speaker’s gavel. When Speaker John Boehner, an Ohio Republican, resigned from the House in 2015 after dealing with rebellions in his ranks, McCarthy, was widely seen as a favorite to replace him. But he backed down in the face of opposition from his party’s right.

McCarthy, 57, spent much of last year trying to win over a faction of conservatives who had a list of grievances about House rules, ire over compromises with Democrats and a lack of trust in the Californian’s claim to conservative credentials.

Biggs, one of the leaders of the revolt, said earlier in the week that McCarthy “has a history that is off-putting to some people.” He voted against him in the 14th round of votes but switched to “present” in the 15th and final one.

Like most House speakers, McCarthy comes into the job with a vast fundraising network. He raised nearly $26.5 million last cycle, more than any other member of the House. And the McCarthy-aligned Congressional Leadership Fund Super PAC raised nearly $260 million. Of the 20 hardliners that opposed McCarthy in the first 11 ballots for the speakership, 14 of the holdouts received some of the largess from McCarthy’s fund. 

But notably, some of McCarthy’s most fervent detractors — including Representatives Lauren Boebert of Colorado and Gaetz — didn’t receive any funds from McCarthy’s PAC.

--With assistance from Jarrell Dillard, Zach C. Cohen, Mike Dorning, Emily Wilkins and Laura Davison.

(Updates with McCarthy on Trump, in 10th paragraph. An earlier version corrected the identification of Representative Richard Hudson, in the sixth paragraph.)

©2023 Bloomberg L.P.