By the slimmest of margins, the House of Representatives passed the Republican plan to replace Obamacare Thursday afternoon, sending the measure to a skeptical Senate where it is almost certain to change shape. Republicans passed the bill by a vote of 217 to 213, just one vote over the 216 needed.

The vote was a big win for House Speaker Paul Ryan, who was able to deliver on Republicans' seven-year long campaign promise to repeal the Affordable Care Act even though the bill doesn't constitute a complete repeal. And for President Donald Trump, this gives him his first legislative victory since taking office more than 100 days ago.

Following the vote, House Republicans were met by protesters chanting "shame" outside the Capitol as they boarded buses for a trip down Pennsylvania Avenue to participate in a celebratory appearance with Trump, who lauded the members.

"They're not even doing it for the party," he said as he stood flanked by Republican leadership and rank and file in the Rose Garden. "They're doing it for this country because we suffered with Obamacare."

Ryan took to the floor ahead of the vote to argue that Obamacare was failing. "We can continue with the status quo or we can put this collapsing law behind us and end this failed experiment," he said.

Related: Trump, GOP Leaders Take Victory Lap

Still, the bill's passage was arduous. Republicans had been working to piece together a GOP-only coalition of votes ever since their attempt to repeal and replace much of the Affordable Care Act failed nearly two months ago

The measure barely made it through, with 20 Republicans splitting with their own party to vote against the bill.

Of the dissenting Republicans, nine represent districts that voted for Democrat Hillary Clinton over Trump in 2016. An additional four lawmakers reside in districts that only narrowly voted for Trump, making them top targets for Democrats seeking to unseat them in next year’s midterms.

Republicans erupted in cheers when the measure passed, and Democrats erupted in song, singing "na, na, na, na, hey, hey, hey, goodbye," alluding to their political futures after the vote.

In a news conference following the vote, Democrats said Republicans voted to take health care away from millions of people.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"Right now, the Republicans are having a beer party to celebrate one of the biggest transfers of wealth from working families to the richest people in our country," House Minority Leader Nancy Pelosi said.

"As I've said, this vote will be tattooed to them. As I've also said, they will glow in the dark," she added. "Any moderate in the crowd who voted for this bill, turned radical today."

Needing every vote they could get, Rep. Jason Chaffetz, R-Utah, returned to Washington immediately after foot surgery to help his colleagues pass the bill.

"It was going to be a tight vote and I didn't want to be the one missing the vote," Chaffetz said, making his around with a bandaged foot and a walking aid. "It was important to be here. The doctor didn't want me to be here but you just have to do it sometimes, so here we are,"

Many in the GOP credited the president for helping get the bill across the finish line.

“This is a good day for the American people and the president of the United States. He personally engaged in a real way to make a difference,” said Rep. Mark Meadows, R-N.C. before the vote.

Meadows had been working his conservative members to agree to the measure as the vote neared. Trump had threatened to run a primary against Meadows and fellow conservatives after the bill’s failure in March.

Related: Here's What You Need to Know About the GOP Health Care Bill

Last minute deals, including promises to some members on future legislation and an additional $8 billion for people with pre-existing conditions in the current bill, helped to get squeamish moderates on board after previous amendments convinced the conservative caucus. It was a move that opened the doors for leadership to find enough votes.

After all the wrangling to get through the House, the bill is sure to undergo extensive changes in the more moderate Senate.

Sen. Bob Corker, R-Tenn, said that the House bill has “zero” chance of passing the Senate.

“That's not the way it's going to work, to be honest,” Corker said on MSNBC’s “Morning Joe.” “People are going to want to improve it. I don't see any way that it goes back in the form that it comes.”

Immediately following the bill's passage in the House, Sen. Rob Portman, R-Ohio, released a statement that he is opposed to the bill.

"Congress must take responsible action that lowers health care costs, but these changes must be made in a way that does not leave people behind," Portman said.

The Senate, however, will not need any Democrats to pass it because they are using a procedural mechanism that allows the bill to pass with just 51 votes instead of the usual 60-vote threshold. There are 52 Republicans in the Senate.

The House measure came to the floor without an updated accounting of how much the bill will cost or its impact. The last assessment, which was done before the bill was altered, said that 24 million people would lose insurance, it would save $300 million and premiums would go down ten percent after ten years.

Rep. Barry Loudermilk, R-Georgia, said that having no updated Congressional Budget Office score is slightly concerning.

“It is a concern, but at this point we have to move forward. The American people are clear they want this done, so I think we have to strike when the iron’s hot,” he said.

Consumer advocacy groups have expressed concern for the bill, saying that it won’t adequately protect patients. Meanwhile, the conservative, small-government political groups such as Club for Growth and Heritage Action have come out in support of the measure.

Rep. Raul Labrador, R-Idaho, one of the most conservative members of Congress, said he will vote for the bill. But when asked if he can guarantee that no one would lose coverage under the GOP plan, he could not.

“What I can guarantee is that more Americans will be helped by this plan than Obamacare has helped,” he said. “More people will have their premiums lowered, more people will have lower out of pocket costs more people will have access to these high risk pools.”

The legislation was made more conservative throughout the process to appeal to members like Labrador who wanted nothing short of a complete repeal of the Affordable Care Act.

Here are the key measures in the House bill: