Senators have voted against a "skinny repeal" bill that would have rolled back health provisions under Obamacare.

Critics had warned that the measure would have led to the additional deaths of tens of thousands of people.

Republican senator John McCain was among those to defy the President and vote against the bill.

The vote deals a serious blow to Mr Trump's legislative agenda after a night of high suspense in the US Capitol.

In an impassioned speech the day he returned to Washington following his cancer diagnosis, Mr McCain had called for bipartisanship on major issues of national concern.

Three Republicans joined with all Democrats to reject the amendment, which would have repealed a mandate that most individuals get health insurance and suspended a requirement that large companies provide coverage to their employees.

It would have also delayed a tax on medical devices and denied funding to Planned Parenthood for a year.

The Congressional Budget Office had warned that 22 million more people would not be covered by health insurance if the repeal of the Affordable Care Act – otherwise known as Obamacare – had gone ahead.

Researchers have established a link between health insurance and mortality, with a recent study suggesting the move could lead to excess deaths totalling more than 20,000.

The final vote in the Senate was 49-51. Republicans Lisa Murkowski of Alaska and Susan Collins of Maine joined Mr McCain in voting no.

"This is clearly a disappointing moment," Senate Majority Leader Mitch McConnell said on the floor after the vote.

"I think the American people are going to regret that we couldn't find a better way forward," he said.

Despite controlling the Senate, the House and the White House, Republicans have struggled for months with repealing Obamacare, a complex law approved by Democrats in 2010 under former President Barack Obama that provided health insurance to millions of previously uninsured Americans.

Mr Trump, who campaigned for the White House on promises to repeal Obamacare, has offered no legislation of his own and little guidance to the Senate, although he has berated them for their inaction.

Republicans hold 52 seats in the 100-seat Senate and McConnell could only afford to lose support from two Republican senators, with the tie-breaking vote to be cast by Vice President Mike Pence, who was on the Senate floor.

Trump spokesman compares attempt to repeal Obamacare to abolition of slavery

Mr Trump has singled out Ms Murkowski for criticism, saying on Twitter that she had let down the Republican Party and the country.

Mr McCain, who flew back from Arizona after being diagnosed with brain cancer in order to vote, was approached minutes before the vote by Mr Pence and Republican Senator Lindsey Graham.

Mr Graham had said on Thursday he had decided to vote for the skinny bill after reassurances from House Speaker Paul Ryan that it would not become law.

After speaking to Mr Pence and Mr Graham for some time, Mr McCain walked across the floor to tell Senate Minority Leader Chuck Schumer and Senators Dick Durbin, Elizabeth Warren, Amy Klobuchar and Dianne Feinstein that they had his vote.

Cheers erupted in the Senate chamber as Mr McCain cast what was believed to be the deciding "no" vote.

After the bill's failure, Mr Schumer told the Senate that it was time to heed Mr McCain's call this week to return to a more transparent and bipartisan legislative process.

"He's a hero, he's a hero of mine," Mr Schumer told reporters after the vote.