The vote - held in the dead of night - came down to the wire, with the decisive moment resting with Senator John McCain, recently diagnosed with brian cancer, who sided with two moderate Republicans in voting with Democrats to oppose the legislation.
"This was a disappointment, a disappointment indeed," Senate Majority Leader Mitch McConnell told colleagues after one of the most tense votes in years on the Senate floor.
"I regret that our efforts were simply not enough this time."
US President Donald Trump urged Republican congressional leaders Friday to let Obamacare "implode" rather than immediately work to fix it.
The collapse marks a major setback for Republican leadership and for Trump, who had campaigned relentlessly on a pledge to repeal and replace the Affordable Care Act passed under his predecessor Barack Obama in 2010.
Friday's vote, which capped a series of failed efforts in recent months to get an Obamacare repeal measure over the line, was on a so-called "skinny repeal" bill that would have rolled back only parts of Obamacare but kept the bulk of the law intact.
It crashed to defeat, 49-51.
Senate leadership had never intended "skinny repeal" to become law, but rather to serve as a vehicle with which to join forces with House Republicans and craft a broader repeal-and-replace plan.
The vote was always going to be close, with Senate Republicans Susan Collins and Lisa Murkowski telegraphing that they would oppose the measure.
Vice President Mike Pence was brought to the chamber around midnight, in case he would be needed to break a 50-50 tie.
But he never got the opportunity, as McCain, whose war hero status was mocked by Trump in 2015, refused to cave to pressure to get on board.
While several Democrats clapped when McCain cast his "no" vote, the mood remained somber in the chamber after the defeat.
"We are not celebrating; we are relieved," said top Democrat Chuck Schumer.
"Let's turn the page and work together to improve our health care system," he added.