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 deaths of up to 20,000 additional 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 final vote 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…