The Republican-sponsored American Health Care Act (AHCA) passed the House 217-213 Thursday, with one vote to spare, although it will face an uncertain path in the Senate.

No Democrats voted for the bill, and 20 Republicans voted against it. The bill largely repeals and replaces Obamacare.

Speaking to reporters after the vote, House Majority Whip Steve Scalise, R-Louisiana, said he knew they had the votes on Wednesday and he said if they hadn't passed it, it would have impeded "the rest of our agenda."

Get Breaking News Delivered to Your Inbox

"We proved that we could accomplish something this big," he said. "I can't thank the president enough. President Trump and Vice President Pence have been directly engaged," adding that Pence called him twice on Thursday to check in about individual members.

House Republicans left the Capitol after the vote, headed to the White House on buses. Scalise said they were invited to the Oval Office or the Rose Garden.

As soon as Republicans cleared the threshold to pass the bill, House Democrats began singing in unison, "Nah, nah, nah, nah, nah, nah, nah, nah, hey, hey, goodbye" toward the Republicans.

Rep. Chris Collins, R-New York, said he's not worried about Republicans' prospects for the 2018 midterm elections.

"If we weren't able to repeal and replace Obamacare, it would have been a bad midterm for us. I think we will hold our own, if not pick up seats," he told reporters.

House GOP leaders expressed confidence earlier that the bill would indeed pass.

"This will pass," House Majority Leader Kevin McCarthy, R-California, told reporters as he left a closed-door meeting with the House Republican Conference. House Majority Whip Steve Scalise, R-Louisiana, also seemed confident that the bill would pass.

The upbeat mood ahead of the key vote comes after weeks of trying to revive their original version of the bill, which failed to win enough support in March and had to be pulled from the floor. Republicans, however, have since made several revisions to the measure -- with the latest one made on Tuesday after skeptical members met with President Trump at the White House. Rep. Fred Upton, R-Michigan, proposed an amendment to the bill that would add $8 billion over five years to cover insurance for people with pre-existing conditions. The addition appeared to sway members who previously opposed the bill, as well as those who were undecided.

"I like the Upton amendment," Rep. Lou Barletta, R-Pennsylvania, told reporters after huddling with his colleagues Thursday. "Actually, it puts more money in the high-risk pools for those with pre-existing conditions, and the fact of the matter is those with pre-existing conditions would have no insurance because the Affordable Care Act is going to totally fail."

Other GOP lawmakers said that their plan was a much more sustainable alternative to Obamacare.

"This is about delivering much more affordable healthcare in contrast to a collapsing Obamacare," said Rep. Kevin Brady, R-Texas, chairman of the powerful tax-writing House Ways and Means Committee. He added that it "creates momentum for tax reform" and takes $1 trillion of tax hikes out of the economy that he said have been hurting patients and small businesses.

For weeks, Speaker Paul Ryan, R-Wisconsin, insisted that the bill would only come to the floor when Republicans had the votes to pass it. They can only afford 21 defections, assuming all Democrats vote against it. Rep. Dan Newhouse, R-Washington, will miss the AHCA vote, his office confirmed to CBS News. He's out of town due to a family emergency. This means that Republicans can afford 21 defections.

After huddling Wednesday night, House GOP leaders decided to move forward and schedule the vote for Thursday afternoon, despite the lack of a score from the nonpartisan Congressional Budget Office (CBO), which estimates how it would affect the federal deficit and Americans with health insurance. The CBO's score of the original bill estimated that 24 million people would lose their insurance over the course of a decade.

Asked about the concern that the final bill hasn't been scored, Collins said, "We have the score on the base bill that saves billions and billions of dollars."

Collins, the first House member to endorse Mr. Trump during the 2016 campaign, said that while the original CBO score showed it would reduce premiums and save money, he doubted its prediction about 24 million people losing their coverage.

"I don't think there was any accuracy in that," he said. "This isn't a tough vote. This is a vote we promised America. This is living up to our promise to repeal and replace Obamacare which is failing minute by minute and day by day."

But some, like South Carolina Republican Sen. Lindsey Graham, still expressed concern.

A bill -- finalized yesterday, has not been scored, amendments not allowed, and 3 hours final debate -- should be viewed with caution. — Lindsey Graham (@LindseyGrahamSC) May 4, 2017

The bill would, among other things, repeal the individual and employer mandates put in place by Obamacare that has required people to carry insurance or face a tax penalty, it would provide refundable tax credits to help people afford coverage, expand health savings accounts and phase out an expansion of Medicaid.

Health and medical advocacy groups have slammed the legislation through all of its forms. The president of the American Medical Association, Andrew W. Gurman, warned Wednesday "millions of Americans will lose their health insurance as a direct result of this proposal."

Meanwhile, the chairman of the Freedom Caucus, Rep. Mark Meadows, R-North Carolina, said he's looking forward to what the Senate will produce.

"It'll come back even better, and that we'll get it passed and finally lower premiums for the American people," he said. "I've talked to over 14 different senators on this subject and I'm very optimistic that we'll find some common ground."

CBS News' Walt Cronkite, Major Garrett, Katherine Watson contributed to this report.