The rescue effort that pulled the Republicans back from the brink of failure on health care began quietly, with two House members who are not exactly household names trying to find common ground on a little-noticed issue.

They were Rep. Tom MacArthur (R-N.J.), a leader of the moderate House Republican bloc that calls itself the Tuesday Group, and Rep. Mark Meadows (R-N.C.), chairman of the conservative and hard-line House Freedom Caucus. The question at hand was giving states more flexibility by allowing them to come up with their own ways of achieving cost savings and providing coverage.

MacArthur — a goateed former insurance executive who once worked on claims with President Trump’s late father — decided to take a stab at it.

While staying at the beach with his family over the House’s two-week Easter recess last month, “I took pen to paper,” MacArthur recalled. “I presented it to the speaker and talked about it with Mark Meadows, and it got life. It moved.”

That amendment allowing states to opt out of some central provisions of the Affordable Care Act was the first breakthrough in the resurrection of the GOP health-care bill — a far different process from the top-down one that led to the failure of the Republicans’ attempt to bring a bill to the floor in mid-March.

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

As the two members traded offers back and forth on a Word document, Speaker Paul D. Ryan (R-Wis.) stayed in the background, urging them on by text and phone and lending his health-care adviser Matt Hoffmann for technical assistance.

Key White House players — Vice President Pence, budget director Mick Mulvaney, Chief of Staff Reince Priebus and top strategist Stephen K. Bannon — were also staying in close touch with the progress of the amendment as Meadows and Mac­Arthur worked out their agreement and pitched it to colleagues. MacArthur noted that some of his fellow moderates were miffed at him for working with the Freedom Caucus leader.

To get the last few votes, two other GOP members — Fred Upton of Michigan and Billy Long of Missouri — would have to step in with yet another change, adding $8 billion over five years to try to help provide coverage for people with serious, preexisting health conditions. They presented their deal to Trump in the Oval Office on Wednesday.

The first and second incarnations of the health legislation represent a steep, six-week learning curve on the part of the Republicans who now control Washington.

That earlier drive crashed when the Ryan plan, crafted with little input from his rank-and-file members, failed to garner enough support from either the conservative or moderate factions of the party. It was an epic embarrassment that raised questions of how prepared they were to govern as a majority and deliver on their promises.

The speaker was not the only one who miscalculated in that initial foray. Trump had assumed that the force of his personality was his best asset in pushing the bill through. He summoned House members to the White House for negotiating sessions that were more theatrical than substantive; threatened Meadows that if he didn’t support it, “I’m coming after you”; and laid down an empty ultimatum that he would walk away from the issue.

If his first big legislative victory has taught Trump anything, it may be that the art of the deal in Washington requires subtlety, patience and — most uncharacteristic for him — a willingness to step back and play a supporting role.

(U.S. House of Representatives)

“One of the great things about this process was we in the White House and the members of the House really got to know each other,” Priebus said in an interview. “If it wasn’t this hard, we wouldn’t have gotten to know each other. I think now the process moving forward on tax reform is going to be perhaps easier in the sense that we learned a lot of lessons, but we also learned a lot about each other.”

Not everyone who voted for the finished product was entirely happy with it, but the process represented a trust-building exercise within the often-fractious House Republican conference.

Rep. Mark Sanford (R-S.C.), a Freedom Caucus member who opposed the earlier version of the legislation, said the MacArthur-Meadows amendment, not whipping from the leadership or the White House, prompted him to back the bill.

Unlike last time around, Sanford said, it was other conservative Republicans and Freedom Caucus leaders who made the case to him, not the White House: “It’s been quieter from [the White House]. This has been bottom-up driven from a member standpoint.”

Even amid their celebrations, Republicans are well aware that passing the bill was less a legislative triumph than a triage operation.

They had made “repeal and replace Obamacare” an article of faith with their conservative constituents and had symbolically voted to do so dozens of times when Barack Obama was president.

As GOP leaders scrambled to bring the last holdouts aboard in recent days, they made the argument that the liberal base is already on fire, anxious to take back control of the House in next year’s midterm elections. That means Republicans could ill afford to fall short on their health-care promise and risk depressing their own turnout.

“Are we going to be men and women of our word?” Ryan implored from the well of the House, moments before the vote.

In a private meeting with her fellow Republicans earlier in the day, Arizona Rep. Martha McSally, previously counted among the undecided, expressed the urgency of the moment in salty terms that evoked her days as an Air Force fighter pilot: “Let’s get this f---ing thing done!”

Lawmakers of both parties also know that the difficulty of their effort to rewrite the health-care law only increases from here, as it moves to even more treacherous territory in the Senate.

In that chamber, the divisions are sharper and deeper between conservative stalwarts and more-moderate senators from states that have expanded Medicaid under the Affordable Care Act, who are worried about their constituents losing coverage.

“I don’t support the House bill as currently constructed because I continue to have concerns that this bill does not do enough to protect Ohio’s Medicaid expansion population, especially those who are receiving treatment for heroin and prescription drug abuse,” Sen. Rob Portman (R-Ohio) said in a statement issued shortly after the vote.

The freewheeling Senate also operates under different rules, with unlimited amendments. That virtually guarantees that the version the Senate passes — if it can pass one at all — will look drastically different from the House bill, potentially sending the whole endeavor back to the starting gate.

The difficulty of uniting House Republicans around what has been a seven-year priority for the GOP may not bode well for the future of Trump’s agenda, especially in areas where ideological unity is not as strong as it is on health care.

Trump’s $1 trillion infrastructure plan, for example, is driven by a populist instinct. More fiscally conservative lawmakers do not share his enthusiasm for major new federal spending on massive construction projects in working-class communities. On tax cuts, deficit hawks could revolt if they see sweeping cuts unbalanced by reductions in spending or areas of new revenue.

On health care, by contrast, the president had come to the debate with few concrete proposals beyond his often-repeated promise to replace Obamacare with “something really, really great.”

Trump had not delved deeply into the policy choices. “On health care, what he wanted was the taxes out and he wanted to get rid of the mandate [requiring people to have coverage or pay a fine], but he wanted to keep all the goodies,” said Trump adviser and former campaign aide Sam Nunberg.

Nor had congressional Republicans, for all their years of railing against the law, done much to come up with a consensus on how to replace it.

The slogan “repeal and replace” — dreamed up in a strategy session in the office of Sen. Mitch McConnell (R-Ky.) in March 2010, the day before Obama signed the law — had been their talisman, warding off questions about their own vision for transforming a medical system that accounts for one-sixth of the U.S. economy.

All of that changed with Trump’s surprise election in November, which put the party in control of the White House, in addition to both houses of Congress.

“It is real easy to be unified when your vote doesn’t matter and you’re in the minority,” Meadows told reporters Thursday. “It is much more difficult to be unified when you’re in the majority. That’s what we’re seeing.”

That failed effort to pass a bill on the first try in March left Trump frustrated and angry at Ryan and Priebus, a longtime friend and ally of the speaker. The president had been blindsided by assurances that a deal was in hand, several people who have talked to him about the matter said, speaking about their private conversations on the condition of anonymity.

“He’s been killing Reince on this,” said one, who added that a defeat on the second go-round would have been a significant blow to the chief of staff’s credibility in the eyes of his boss.

The second time around, the White House kept its own vote counts and was more aggressive in negotiating directly with the various factions in the House.

Trump celebrated his first legislative victory by summoning Republicans to the White House Rose Garden, almost as if the bill had already passed into law. But MacArthur, as he left the White House, warned that it is far too early to declare victory.

“Feel good it passed,” he said, pausing. “But at the same time, we’ve got to be mindful that a lot of Americans are worried and it’s time for us to go home and tell people how it’ll benefit them. Help them understand.”

MacArthur summed up the work ahead in two words: “Selling it.”

Read more:

The Debrief: Trump crows about his health-care victory — even though he hasn’t really won yet

While House passes GOP health-care bill, Senate prepares to do its own thing

Philip Bump: This is not the health-care bill that Trump promised

Paul Kane and Kelsey Snell contributed to this report.