President Donald Trump suffered a stunning political setback on Friday in a Congress controlled by his own party when Republican leaders pulled legislation to overhaul the U.S. health-care system, a major 2016 election campaign promise of the president and his allies.

Republican leaders of the House of Representatives pulled the legislation due to a shortage of votes despite desperate lobbying by the White House and its allies in Congress, ensuring that Trump's first major legislative initiative since taking office on Jan. 20 ended in failure.

House Republicans had planned a vote on the measure after Trump late on Thursday cut off negotiations with Republicans who had balked at the plan and issued an ultimatum to vote on Friday, win or lose.

Republican moderates as well as the most conservative lawmakers had objected to the legislation. The White House and House leaders were unable to come up with a plan that satisfied both moderates and conservatives, despite Trump's vaunted image as a deal maker.

The House failure to pass the measure called into question Trump's ability to get other key parts of his agenda, including tax cuts and a boost in infrastructure spending, through Congress.

News that the bill had been pulled before a final vote was greeted initially with a small sigh of relief by U.S. equity investors, who earlier in the week had been fretful that an outright defeat would damage Trump's other priorities, such as tax cuts and infrastructure spending.

Benchmark U.S. stock market indexes ended the session mixed after rallying back from session lows following the news. The S&P 500 Index ended fractionally lower, the blue chip Dow Jones Industrial Average slipped about 0.3 per cent and the Nasdaq Composite Index rose about 0.2 per cent.

The U.S. dollar also strengthened modestly on the news and U.S. Treasury bond yields edged up from session lows.

"There's nobody that objectively can look at this effort and say the president didn't do every single thing he possibly could with this team to get every vote possible," White House spokesman Sean Spicer told reporters before the legislation was pulled.

Trump already has been stymied by federal courts that blocked his executive actions barring entry into the United States of people from several Muslim-majority nations. Some Republicans worry a defeat on the health-care legislation could cripple his presidency just two months after the wealthy New York real estate mogul took office.

In a blow to the bill's prospects, House Appropriations Committee Chairman Rodney Frelinghuysen announced his opposition, expressing concern about reductions in coverage under the Medicaid insurance program for the poor and the retraction of "essential" health benefits that insurers must cover.

"We need to get this right for all Americans," Frelinghuysen said.

Trump sought to shift the blame to the Democrats, who were united in their opposition, even though his party controls the White House, the House and the Senate.

"We learned a lot about loyalty. We learned a lot about the vote-getting process," Trump told reporters at the White House.

Amid a chaotic scramble for votes, House of Representatives Speaker Paul Ryan, who championed the bill, met with Trump at the White House before the bill was pulled from the House floor after hours of debate. Ryan said he recommended that the legislation be withdrawn from the House floor because he did not have the votes to pass it, and that Trump agreed.

"There were things in this bill that I didn't particularly like," Trump added, without specifying what those were, but expressed confidence in Ryan's leadership.

"Perhaps the best thing that could happen is exactly what happened today, because we'll end up with a truly great health-care bill in the future after this mess known as Obamacare explodes," Trump said.

Friday's events cast doubt on whether Ryan can get major legislation approved by fractious Republican lawmakers.

"I will not sugarcoat this. This is a disappointing day for us," Ryan said at a news conference, adding that his fellow Republicans are experiencing what he called "growing pains" transitioning from an opposition party to a governing party.

"Doing big things is hard," Ryan added, noting that he got close but failed to muster the 216 votes needed to pass it.

Ryan said he did not know what the next steps would be on health care, but called Obamacare so flawed that it would be hard to prop up.

Without the bill's passage in Congress, Democratic former President Barack Obama's signature domestic policy achievement, the 2010 Affordable Care Act — also known as Obamacare — remains in place despite seven years of Republican promises to dismantle it.

Repealing and replacing Obamacare was a top campaign promise by Trump in last year's presidential election, as well as by most Republican candidates, "from dog-catcher on up," as Spicer put it during a briefing on Friday.

Republican Representative Dana Rohrabacher said before the bill was pulled that voting it down would be "neutering Trump" while empowering his opponents.

"You don't cut the balls off a bull and then expect that he can go out and get the job done," Rohrabacher told Reuters. "This will emasculate Trump and we can't do that ... If we bring this down now, Trump will have lost all of his leverage to pass whatever bill it is, whether it's the tax bill or whatever reforms that he wants."

Trump and House Republican leaders could not afford to lose many votes in their own party because Democrats were unified in opposition, saying the bill would take away medical insurance from millions of Americans and leave the more-than-$3 trillion U.S. health-care system in disarray.

Republican supporters said the plan would achieve their goal of rolling back the government's "nanny state" role in health care.

Obamacare boosted the number of Americans with health insurance through mandates on individuals and employers, and income-based subsidies. About 20 million Americans gained insurance coverage through the law.

The nonpartisan Congressional Budget Office said under the Republican legislation 14 million people would lose medical coverage by next year and more than 24 million would be uninsured in 2026.

Days of negotiations involving Republican lawmakers and the White House led to some changes in the bill but failed to produce a consensus deal.

The House plan would rescind a range of taxes created by Obamacare, end a penalty on people who refuse to obtain health insurance, end Obamacare's income-based subsidies to help people buy insurance while creating less-generous age-based tax credits

It also would end Obamacare's expansion of the Medicaid state-federal insurance program for the poor, cut future federal Medicaid funding and let states impose work requirements on some Medicaid recipients.

House leaders agreed to a series of last-minute changes to try to win over disgruntled conservatives, including ending the Obamacare requirement that insurers cover certain "essential benefits" such as maternity care, mental health services and prescription drug coverage.