House Speaker Paul D. Ryan (R-Wis.) retreated to the back of the chamber, setting his arm on a banister and resting his head on his hand. He was done trying to coerce the recalcitrants.

Finally, Ryan looked at his aides and flicked his hands in the air, making the symbolic motion of washing his hands of the matter.

The bells sounded, the vote began Friday morning and, when the gavel fell, another defeat was at hand.

Ryan’s final seven months as speaker are not likely to be any easier than his first few years. Much of Friday’s rebellion in the House had a familiar feel — the far-right Freedom Caucus issued demands on immigration legislation and then took hostage an unrelated bill, on farm policy and food stamps, to try to maximize leverage.

But the conservative revolt was different this time. It was actually rooted in a moderate uprising on immigration that began two weeks ago and appeared headed toward success, so the conservatives felt the need to inject themselves into the battle.

Now, Ryan finds himself fighting a two-front war on the most politically treacherous issue in GOP politics. If not handled deftly, the issue threatens to dominate the summer and fall, possibly right up until the November midterm elections.

House Speaker Paul D. Ryan (R-Wis.) emerges from the Capitol chamber just after the farm bill failed Friday. (J. Scott Applewhite/AP)

Some lawmakers see a lame-duck speaker whose already fractious caucus might feel a bit more free than ever to rebel because he is heading for the doors without a clear successor.

“In the absence of decisive or strong leadership, personalities begin to assert themselves, interests begin to assert themselves,” said Rep. Mark Sanford (R-S.C.), one of 30 Republicans who took down the farm bill over demands that their favored conservative immigration bill receive a vote.

That action brought sharp denunciations from the rest of the rank-and-file Republicans who needed every vote from their side of the aisle to pass a farm bill that would also include strict new changes to food-stamp programs. Instead, Democrats happily watched as Republicans broke apart on a bill whose primary beneficiaries are rural farmers, who overwhelmingly support President Trump and Republicans.

“You have a number of Republicans constantly voting with Nancy Pelosi,” said Rep. Mario Diaz-Balart (R-Fla.), referring to the House minority leader from California.

Diaz-Balart is one of the centrist GOP ringleaders trying to force votes on immigration legislation that would grant permanent legal status, or possibly citizenship, to at least 800,000 undocumented immigrants, known as “dreamers,” who were brought to the country illegally as children.

On May 9, he joined 14 other Republicans in signing a “discharge petition,” which can circumvent the committee process and leadership if 218 lawmakers sign on. Several bills would get voted on, and the one most likely to pass would be a bipartisan plan to give permanent residence to dreamers and to enhance border security — a bill that conservatives consider anathema.

With 193 Democrats in the House, the centrists need at least 25 Republicans to push the issue to the floor. They quickly reached 20 GOP signatures, and it became abundantly clear that many more Republicans were willing to sign.

“Doing nothing, as I’ve said for months, is not an acceptable position on this,” said Rep. Tom Reed (R-N.Y.), who supports Diaz-Balart’s position but has not yet signed on out of respect for Ryan. Reed doesn’t see the issue as a big one in his district, but he said that he is tired of the dysfunction driven by Freedom Caucus demands.

Since 2010, time and again, conservatives have frozen House GOP leaders by threatening to try to oust the speaker — Ryan, and before him John A. Boehner (R-Ohio) — if they allowed compromise legislation to pass with Democratic votes, particularly on immigration.

Those conservatives hail from deep-red districts and do not fear for their own political mortality, a luxury moderates cannot afford. Increasingly worried about their own standing in swing districts, where mass deportation is politically toxic, the centrists staged their own revolt on immigration and sent a message to the Freedom Caucus about its roadblock strategy.

“If that’s the way it’s going to be, we have to obviously be part of efforts to break that and to try to force this system to work a little bit better,” Reed said. “Rather than be held hostage by a certain small number of folks.”

A discharge petition has succeeded only once in the past 15 years, during a leadership vacuum in October 2015. Boehner had announced he was resigning, and House Majority Leader Kevin McCarthy (R-Calif.), the heir apparent, bowed out when he realized he lacked sufficient support. Dozens of Republicans joined Democrats in signing a petition that forced an eventually successful vote to reauthorize the Export-Import Bank of the United States.

Ryan’s current leadership team has more clout than that group did three years ago. He spent the past week haggling with the centrists and came close to a deal that would allow leadership to set the terms of an immigration debate next month, with votes on several different bills.

The centrist wing appeared ready to accept that deal, but the Freedom Caucus demanded its own vote on the most conservative immigration proposal.

Now, senior Republicans fear that Reed and other moderates who have held back will sign the discharge petition, taking all power on the issue away from Ryan.

“It gives more leverage on the discharge petition, which, I think, is highly destructive,” Rep. Patrick T. McHenry (R-N.C.), one of the top vote-counters, said after Friday’s failed vote.

Was this just an effort to embarrass Ryan and McCarthy?

“The fact is, if you’re in House leadership, in either party, embarrassment is just certainly part of the process,” McHenry mused.

Come January, someone other than Ryan will have to got get their hands dirty — McCarthy, another Republican or maybe a Democrat — managing embarrassing moments like this.

Read more from Paul Kane’s archive, follow him on Twitter or subscribe to his updates on Facebook.

Correction: An earlier version of this story misspelled the name of Rep. Mark Sanford (R-S.C.).