Three Republican senators - John McCain, Susan Collins and Lisa Murkowski - joined Senate Democrats in the dramatic early-morning 51-49 vote rejecting the bill. The outcome may spell doom for the party's seven-year quest to gut a 2010 law that was Democratic former President Barack Obama's signature domestic policy achievement.
Senate Majority Leader Mitch McConnell was unsuccessful in securing passage of even a stripped-down so-called skinny bill that would have repealed a few key parts of Obamacare. Broader legislation was defeated earlier in the week.
"It's time to move on," McConnell, whose reputation as a master strategist was in tatters, said on the Senate floor after the vote that unfolded at roughly 1:30 a.m.
"This is clearly a disappointing moment," McConnell added. "The American people are going to regret that we couldn't find a better way forward."
The Senate's action also means that the Affordable Care Act, which extended health insurance to 20 million people and drove the percentage of uninsured people to historic lows, remains in place and must be administered by an administration hostile to it. Republicans have long denounced Obamacare as an intrusion by government on people's healthcare decisions.
The failure called into question the Republican Party's basic ability to govern even as it controls the White House, Senate and House of Representatives. Trump has not had a major legislative victory after more than six months in office. He had vowed to get major healthcare legislation, tax cuts and a boost in infrastructure spending through Congress in short order.
"3 Republicans and 48 Democrats let the American people down. As I said from the beginning, let Obamacare implode, then deal. Watch!" Trump wrote on Twitter after the vote.
Republicans released the skinny bill just three hours before voting began. It would have retroactively repealed Obamacare's penalty on individuals who do not obtain health insurance, repealed for eight years a penalty on certain businesses that do not provide employees with insurance and repealed a tax on medical devices until 2020. The nonpartisan Congressional Budget Office estimated that if it became law, 15 million fewer Americans would be insured in 2018 than under existing law.
The Affordable Care Act was passed by a then-Democratic controlled Congress with no Republican support in 2010. But Republicans have failed to come up with a consensus plan to replace it at a time when they hold all the power in Washington.
UNCERTAINTY FOR HEALTHCARE INDUSTRY
The bill's defeat still leaves uncertainty in the healthcare industry, with insurers not sure how long the Trump administration will continue to make billions of dollars in Obamacare payments that help cover out-of-pocket medical expenses for low-income Americans.
Insurers have until September to finalize their 2018 health plans in many Obamacare marketplaces.
Some insurers, including Humana and Aetna, have pulled out of such markets, citing the uncertainty over the payments. Others have raised rates by double digits and said that they will need to raise rates another 20 percent if the uncertainty does not ease. Anthem Inc, which has already left three of the 14 states where it sells Blue Cross Blue Shield plans, said this week it might pull out of more. After the House passed a bill to repeal and replace Obamacare in May, McConnell grappled to get Senate Republicans to agree on their version of the bill. Hard-line conservatives wanted a bill that would substantially gut Obamacare, while moderates were concerned over legislation that could deprive millions of people of their healthcare coverage.
Republicans hold a 52-48 majority in the 100-seat Senate and could afford to lose support from only two Republican senators, with Vice President Mike Pence ready to cast a tie-breaking vote on the Senate floor.
As the vote on the skinny bill approached, all eyes in the Senate chamber were on McCain. The 2008 Republican presidential nominee flew back from Arizona earlier in the week after being diagnosed this month with brain cancer. McCain, an 80-year-old former prisoner of war in Vietnam who tangled with Trump during the 2016 election campaign and was disparaged by him, won praise for this from the president.
McCain, who has long been known for his independent streak, delivered a rousing speech on Tuesday calling for cooperation between the parties and then cast a decisive vote in allowing the Senate to take up the healthcare bill.
Early on Friday, he sat on the Senate floor talking to Collins, Murkowski, and Republican Senator Jeff Flake, also from Arizona.
Collins and Murkowski both voted this week against broader Republican healthcare proposals, and they were both known to have concerns about the pared-down proposal. Trump had criticized Murkowski, tweeting that she had let down the Republican Party and the country.
McCain was then approached before voting began by Pence and Republican Senator Lindsey Graham. Graham had said on Thursday he would support the skinny repeal bill after reassurances from House Speaker Paul Ryan that if passed it would move to a committee of House and Senate lawmakers for changes, rather than being approved outright by the House.
After speaking to Pence and Graham, McCain walked across the Senate floor to tell Senate Minority Leader Chuck Schumer and other Democrats that he would vote with them. They laughed as McCain said that the reporters in the balcony could probably read his lips. Democratic Senator Dianne Feinstein embraced him.
When McCain walked to the front of the Senate chamber to cast his deciding "no" vote, giving a thumbs down, Democrats cheered, knowing the bill would fail.
"Skinny repeal fell short because it fell short of our promise to repeal & replace Obamacare w/ meaningful reform," McCain said later on Twitter.
Trump had often expressed exasperation over the failure of congressional Republicans to overcome internal divisions to repeal Obamacare, but offered no policy specifics himself.
The president has demanded at various times that Obamacare should be allowed to collapse on its own, that it should be repealed without replacement, and that it should be repealed and replaced.
After the bill's defeat, Schumer told the Senate it was time to heed McCain's call to return to a more transparent and bipartisan legislative process.
Democrats, and some Republicans, said the bill's failure could present an opportunity for the two parties to work together to fix problematic areas of the Obamacare law without repealing it.