In a humiliating failure, U.S. President Donald Trump and Republican leaders yanked their bill to repeal Obamacare off the House floor Friday when it became clear it would fail badly — after seven years of nonstop railing against the health-care law.

Democrats said Americans can "breathe a sigh of relief." Trump said Obama's law was imploding "and soon will explode."

It was a stunning defeat for the new president after he had demanded House Republicans delay no longer and vote on the legislation Friday, pass or fail.

His gamble failed. Instead Trump, who campaigned as a master deal-maker and claimed that he alone could fix the U.S. health-care system, saw his ultimatum rejected by Republican lawmakers who made clear they answer to their own voters, not to the president.

He had "never said repeal and replace it in 64 days," a dejected but still combative Trump said at the White House, though he had repeatedly shouted during the presidential campaign that it was going down "immediately."

People march in a 'Save Obamacare' rally in Los Angeles on Thursday, the seventh anniversary of Obama signing his health-care law. (Lucy Nicholson/Reuters)

The bill was withdrawn just minutes before the House vote was to occur, and lawmakers said there were no plans to revisit the issue. Republicans will try to move ahead on other agenda items, including overhauling the tax code, though the failure on the health bill can only make whatever comes next immeasurably harder.

Trump pinned the blame on Democrats.

"With no Democrat support we couldn't quite get there," he told reporters in the Oval Office. "We learned about loyalty, we learned a lot about the vote-getting process."

The Obama law was approved in 2010 with no Republican votes.

'A disappointing day for us,' says Ryan

Despite reports of backbiting from administration officials toward House Speaker Paul Ryan, Trump said: "I like Speaker Ryan.… I think Paul really worked hard."

For his part, Ryan told reporters: "We came really close today but we came up short.… This is a disappointing day for us." He said the president has "really been fantastic."

But when asked how Republicans could face voters after their failure to make good on years of promises, Ryan quietly said: "It's a really good question. I wish I had a better answer for you."

I want to thank <a href="https://twitter.com/POTUS">@POTUS</a>, <a href="https://twitter.com/VP">@VP</a>, <a href="https://twitter.com/SecPriceMD">@SecPriceMD</a>, & <a href="https://twitter.com/HouseGOP">@HouseGOP</a> members. There remains so much we can do to help improve people’s lives. And we will. <a href="https://t.co/JYxgAp9oFn">pic.twitter.com/JYxgAp9oFn</a> —@SpeakerRyan

Last fall, Republicans used the issue to gain and keep control of the White House, Senate and House. During the previous years, they had cast dozens of votes to repeal Obama's law in full or in part, but when they finally got the chance to pass a repeal version that actually had a chance to become law, they couldn't deliver.

Ryan and Trump weakened politically

Democrats could hardly contain their satisfaction.

"Today is a great day for our country, what happened on the floor is a victory for the American people," said House minority leader Nancy Pelosi, who as Speaker herself helped Obama pass the Affordable Care Act in the first place. "Let's just for a moment breathe a sigh of relief for the American people."

The outcome leaves both Ryan and Trump weakened politically.

For the president, this piles a big early congressional defeat onto the continuing inquiries into his presidential campaign's Russia connections and his unfounded wiretapping allegations against Obama.

Watch House Democrats on the fall of <a href="https://twitter.com/hashtag/TrumpCare?src=hash">#TrumpCare</a> here: <a href="https://t.co/nxzlUO8Nfm">https://t.co/nxzlUO8Nfm</a> —@NancyPelosi

Ryan was not able to corral the House Freedom Caucus, the restive band of conservatives that ousted the previous speaker. Those Republicans wanted the bill to go much further, while some Republican moderates felt it went too far.

Instead of picking up support as Friday wore on, the bill went the other direction, with several key lawmakers coming out in opposition. Congressman Rodney Frelinghuysen of New Jersey, chair of a major committee, appropriations, said the bill would raise costs unacceptably on his constituents.

The defections raised the possibility that the bill would not only lose on the floor, but lose big.

24 million additional uninsured under bill

The Republican bill would have eliminated the Obama statute's unpopular fines on people who do not obtain coverage and would also have removed the often-generous subsidies for those who purchase insurance.

Republican tax credits would have been based on age, not income like Obama's, and the tax boosts Obama imposed on higher-earning people and health care companies would have been repealed. The bill would have ended Obama's Medicaid expansion and trimmed future federal financing for the federal-state program, letting states impose work requirements on some of the 70 million beneficiaries.

The nonpartisan Congressional Budget Office said the Republican bill would have resulted in 24 million additional uninsured people in a decade and led to higher out-of-pocket medical costs for many lower-income and people just shy of age 65 when they would become eligible for Medicare. The bill would have blocked federal payments for a year to Planned Parenthood.

After pulling Trump's health-care bill from the House, Speaker Paul Ryan says Obamacare is sticking around for now. 1:20

Republicans had never built a constituency for the legislation, and in the end the nearly uniform opposition from hospitals, doctors, nurses, the AARP, consumer groups and others weighed heavily with many members. On the other side, conservative groups including the Koch outfit argued the legislation did not go far enough in uprooting Obamacare.

Ryan made his announcement to lawmakers at a very brief meeting, where he was greeted by a standing ovation in recognition of the support he still enjoys from many lawmakers.

When the gathering broke up, Congressman Greg Walden of Oregon, chairman of the energy and commerce committee that helped write the bill, told reporters: "We gave it our best shot. That's it. It's done. D-O-N-E done. This bill is dead."