Updated on May 4 at 3:47 p.m. ET

For House Republicans, the burden of an unfulfilled campaign promise had simply become too much to bear alone.

And so on Thursday, after an embarrassing early failure and weeks of fits and starts, a narrow GOP majority passed legislation to partially repeal and replace the Affordable Care Act that even many of its supporters conceded was deeply flawed. The party-line vote was 217-213, with 20 Republicans voting against. The bill now goes to the Senate, where its fate is uncertain at best.

The American Health Care Act scraps the Obamacare mandates that people buy health insurance and that employers provide it, eliminates most of its tax increases, cuts nearly $900 billion from Medicaid while curtailing the program’s expansion, and allows states to seek a waiver exempting them from the current law’s crucial prohibition against insurers charging higher premiums to people with pre-existing conditions. Conservatives complained that the bill did not fully repeal the 2010 law, while moderates blanched at its cuts to Medicaid and its weakening of its most popular consumer protections.

But after a week of cajoling, last-minute amendments, and untold private assurances, President Trump, Speaker Paul Ryan, and their top lieutenants were able to persuade a vast majority of Republicans to sign on. The vote, politically risky though it was, revives the president’s legislative agenda after it appeared to stall in March.

“We’re going to get this passed through the Senate, I feel so confident,” an exultant Trump declared in a victory ceremony at the White House, as dozens of House Republicans stood behind him in the Rose Garden. In his characteristic style, the president described the bill in broad terms and devoted most of his comments to patting both himself and Republican congressional leaders on the back. “I think most importantly, yes, premiums will be coming down,” he said. “Yes, deductibles will be coming down. But very importantly, it’s a great plan, and ultimately that’s what it’s all about.”

Hardliners in the House Freedom Caucus, who had denounced the original version of the bill as “Obamacare-lite,” dropped their opposition after securing an amendment allowing states to opt out of key insurance mandates. Moderates and even some leadership loyalists balked, but they secured an 11th hour sweetener of their own: an extra $8 billion to help people with pre-existing conditions who might not be able to afford higher premiums that insurers could charge them in high-risk pools. The modest sum was no more than a political fig leaf, as policy analysts said it would not come close to making the new insurance pools work. But it gave some lawmakers who wanted to vote yes a reason to do so, and it won over enough holdouts to put the vote over the top.

Though they had barely enough time to read the revised bill, Republican House members voted on Thursday fully aware of the political peril that might await them. Progressive activists had jammed town-hall meetings much as Tea Party conservatives had done to Democratic lawmakers eight years ago. Supporters of Obamacare weaponized a finding by the nonpartisan Congressional Budget Office that the GOP bill would result in 24 million fewer people having health insurance after a decade. Premiums would spike in the first two years after enactment. And Democrats won even more ammunition for the 2018 midterms when Republican leaders rushed the revised measure to the floor without a final estimate from the CBO and barely half a day after the legislative text of last-minute amendments became public. “I would prefer to have it scored, but more than that I want it to pass,” a conservative convert to the AHCA, Representative Mo Brooks of Alabama, admitted to The Washington Post.

Democrats were at once rueful and gleeful. They denounced Republicans for voting to rip health insurance from millions by cutting Medicaid, and for breaking their repeated pledge to uphold protections for people with pre-existing conditions. “God have mercy on your soul,” Representative Sheila Jackson Lee of Texas declared on the House floor. “Make no mistake, people will die as a result of this bill,” said Representative Debbie Wasserman Schultz of Florida, the former Democratic Party chairwoman.

But they also recognized the potential of a political gift, readying attack ads against GOP lawmakers who voted to strip health benefits from their constituents in service of an unpopular president. Republicans won no cover from leading health-care industry groups, who opposed the bill en masse. A widely-cited Quinnipiac University poll in March found that just 17 percent of respondents backed its passage, and that was before Republicans amended the measure to allow states to weaken popular consumer protections. And by holding a vote after limited public hearings, back-room deals, and without fully understanding the impact of the bill, the GOP opened itself up to the same criticisms it leveled (falsely, in some cases) against Democrats in 2010.

“They have this vote tattooed on them. This is a scar they will carry,” warned House Minority Leader Nancy Pelosi, who as speaker in 2010 shepherded the Affordable Care Act to passage. “Whatever happens down the road, the members of the House Republican caucus will be forever identified with the worst aspects of the bill they have passed.” As the vote ended on Thursday, Democrats waved to Republicans and chanted, “Nah nah nah nah, hey hey, goodbye.” It was a taunt Republicans tossed at Democrats back in 1993 when they voted for a tax increase until President Bill Clinton and saw their House majority disappear the next year.

Under intense pressure from the White House, Republicans cast their effort as a rescue effort to save Americans from a “collapsing” health-care law. They cited state after state in which insurers had pulled out of the individual market, leaving few choices and higher premiums for consumers. “This is a crisis, and it is happening,” Ryan said in an impassioned closing floor speech that drew cheers from Republicans. He called for lawmakers to “end this failed experiment” in health policy. “A lot of us have been waiting seven years to cast this vote.” As he wrapped up, Republicans chanted “Vote! Vote!” while Democrats shouted, “Where’s the score?” in reference to the missing budget projection. Meanwhile, Trump watched the vote from the White House, tweeting criticism at Democrats and preparing to welcome Republicans lawmakers for a celebratory press conference in the Rose Garden “if victorious.”

For House Republicans, the dozens of votes to repeal or roll back Obamacare they took over the years had been relatively easy, free of political or substantive consequences because the bills had no chance of becoming law. But this year was different. With control of Congress and Trump in the White House, they were, as more than one member acknowledged over the last several weeks, “shooting with live bullets.” (Their critics put it another way: They were “the dog that caught the car.”)

And yet, what pushed some reluctant members to vote yes in the final days was the growing realization that this bill, too, would not become law. Not as it is currently written. As many hurdles as the American Health Care Act has overcome among Republicans in the House, it faces even more among the considerably narrower GOP majority in the Senate, where party leaders must win over 50 out of the chambers 52 Republicans. Numerous senators have criticized aspects of the legislation, and shortly before the House vote on Thursday, Senator Lindsey Graham of South Carolina warned that the bill should be “viewed with caution.” Afterwards, top senators said they would work on drafting their own legislation, suggesting that the House bill might not even see a vote in the upper chamber.

Conservatives and moderates alike said they based their votes at least in part on the assurance that the Senate would change the bill. “I have a little bit of faith—not a lot—but a little bit of faith that it’s actually going to improve in the Senate,” Representative Raul Labrador of Idaho, a member of the Freedom Caucus, told reporters on Wednesday. Labrador is relying on conservatives like Senators Rand Paul of Kentucky, Mike Lee of Utah, and Ted Cruz of Texas to push the AHCA to the right and to stretch the bounds of what Republicans can pass with a simple majority under the Senate’s budget reconciliation procedure.

Moderate Republicans, meanwhile, are betting that senators like Susan Collins of Maine, Lisa Murkowski of Alaska, and Rob Portman of Ohio will ensure that some of the cuts to Medicaid are restored and protections for people with pre-existing conditions are strengthened. And that’s if the Senate can pass anything at all. Gone are the GOP’s earlier hope, voiced by party leaders in March, that the Senate would simply ratify what the House passed and send it on to Trump for his signature. Senators will now wait up to two weeks for CBO to review the House-passed bill, and then it could take several weeks to agree on revisions, or a new bill entirely, that would then either be sent back to the House or to a conference committee for more negotiations. “The Senate will now finish work on our bill, but will take the time to get it right,” said Senator Lamar Alexander of Tennessee, chairman of the Health, Education, Labor, and Pensions Committee.

The repeal of Obamacare took a big step forward on Thursday, but it is by no means guaranteed.

With their votes, House Republicans are risking the possibility that they’ll have opened themselves up to political attacks for a bill that will die in the Senate. But the alternative, they determined, was just as bad. Failure to so much as vote on their core campaign promise had already humiliated the party, set back their agenda, and threatened to demoralize their conservative base. They needed to unload their burden, and on Thursday, with little margin to spare, they did. Repealing Obamacare is the Senate’s problem now.