(Bastien Inzaurralde,Dalton Bennett,Jayne Orenstein/The Washington Post)

Republicans pushed a health-care bill through the House Thursday that few lawmakers truly liked. They instead viewed the measure as a necessary step to demonstrate some sense of momentum and some ability to govern in GOP-controlled Washington.

Rather than embrace policy cobbled together to replace the 2010 Affordable Care Act, many Republicans simply decided the best move was to approve a flawed bill — and ram it through a flawed process — so that the Senate would get a chance to fix the House’s mistakes, setting up a major negotiation later.

House Republicans did so knowing that their votes will be portrayed by their Democratic opponents as ruthlessly denying millions of people health insurance and causing Americans with preexisting illnesses to shoulder higher costs.

And they did so knowing that there’s a chance the Senate will choke on the legislation or that House and Senate negotiators will deadlock and never agree to a final product — leaving them on record voting for a bill that could have career-ending consequences.

“This bill is highly imperfect, imperfect, okay? There’s no doubt about that,” Rep. Mario Diaz-Balart said after supporting the legislation.

How the House voted to pass the GOP health-care bill.

The Florida Republican — who represents a competitive district — waited until the last 24 hours to come on board. He cited conversations with senators who vowed to address his concerns about how to handle the tens of thousands of his constituents who are signed up for the ACA insurance exchanges.

“Is this bill good? No, I don’t like it,” Diaz-Balart said. But he suggested that voting for the bill would allow him to be part of future negotiations: “So my decision was, how do I stay involved?”

The other critical factor was a desire for the House GOP majority to show it can actually govern.

Inside the leadership team of House Speaker Paul D. Ryan (R-Wis.), there was a gripping fear of what failure would mean for its future overseeing a chamber seemingly incapable of moving important legislation. Ryan had already pulled his American Health Care Act from the floor once, in late March, amid a rebellion on his left and right flanks regarding its shortcomings.

The initial game plan was to simply give up on repealing Obamacare and move on to a broad rewriting of the tax code. But inside the White House, President Trump’s advisers became increasingly concerned about how little they had to show in terms of early victories. They helped nudge the hard-line House Freedom Caucus and some members of the moderate Tuesday Group back to the bargaining table.

Lawmakers produced a deal that eventually brought all but one member of the Freedom Caucus into the fold, and Ryan’s team realized it was as close as Republicans had been to passing the legislation. At that point, wavering members faced pressure to be loyal to the speaker and show that the House could act.

The consequence of failure — for a second time in six weeks, after the humiliating first retreat — became a compelling reason to vote “yes.”

(Jenny Starrs/The Washington Post)

“Some would have said it would have been apocalyptic, that if you, you know, go to the well once and you can’t get there and you go back again and you come up short, it says a lot about your ability to govern and to move legislation of consequence. And so I think it would have had rather significant ramifications,” Rep. Mark Sanford (R-S.C.), a member of the Freedom Caucus, said.

No one publicly spoke about it, but there were whispers that some or all of the House leadership team would fall if the legislation came up short. The fate of Ryan and his lieutenants hovered just beneath the surface — until Trump, with Ryan at his side, cracked a joke about it.

“For the last week I’ve been hearing, ‘Paul Ryan doesn’t have it, it’s not working with Paul Ryan, he’s going to get rid of Paul Ryan.’ Then today I heard, ‘Paul Ryan’s a genius.’ He’s come a long way,” Trump said, smiling at Ryan over his shoulder at a celebratory Rose Garden tribute after the bill’s passage.

Saturday marks the first anniversary of Ryan’s famous announcement that he was “not ready” to endorse Trump for president, launching a tumultuous relationship between the two leaders that lasted through the November election and has always been just underneath their shared attempt to manage Trump’s agenda on Capitol Hill.

In that regard, Trump and Ryan needed a jointly-forged victory, almost any victory, so that they could figure out a way forward. Not just on health care but on other critical items, particularly the tax overhaul, for which Trump has released a plan that is at odds with what the speaker has been working on for several years.

The question is whether this short-term victory was worth the long-term squeeze.

The legislation passed by the narrowest of margins, 217 to 213. Twenty Republicans opposed the legislation, at a time when independent political analysts rate about 40 GOP seats as potentially vulnerable in 2018. If Republicans lose 24 seats, they lose the majority.

A couple of dozen Republicans took risky votes on legislation that, so far, has not proved to be particularly popular among voters.

One of those was sophomore Rep. Carlos Curbelo (R-Fla.), whose district favored Hillary Clinton by nearly 17 percentage points over Trump last year. Curbelo won reelection by a comfortable margin against a flawed Democratic opponent but now finds himself near the top of Democratic target lists for 2018.

Curbelo held out until Thursday afternoon to decide how he would vote. He met regularly with Rep. Fred Upton (R-Mich.), the former chairman of the Energy and Commerce Committee and a leading moderate who negotiated an extra $8 billion in the legislation to lower premiums for those with preexisting conditions.

Even with that key addition, Curbelo still wasn’t sold on the bill. Like many other late-deciding Republicans, he placed his bet on the Senate after conversations with Sen. Marco Rubio (R-Fla.) about his concerns that the tax credits in the House bill are not generous enough to help older workers who aren’t yet eligible for Medicare.

“I want as much of a guarantee as I can get from Senate offices that it is a major priority, and that it’s going to get done,” he said Thursday morning.

If Curbelo gets washed out in the 2018 elections, Trump and Ryan may look back on Thursday as a long-term mistake.

Even Ryan acknowledged the bill that passed Thursday was far from perfect.

“I want to thank all the other members who contributed to making this the best bill possible,” he said in the Rose Garden, adding that much work needs to be done. “Today was a big day, but it is just one step in this process.”

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