Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

WASHINGTON — Obamacare stays. For now.

Senate Republicans failed to pass a pared-down Obamacare repeal bill early Friday on a vote of 49-51 that saw three of their own dramatically break ranks.

Three Republican senators — John McCain, Susan Collins and Lisa Murkowski — and all Democrats voted against the bill, dealing a stinging defeat to Republicans and President Donald Trump who made repeal of Obamacare a cornerstone their campaigns.

The late-night debate capped the GOP's months-long effort to fulfill a seven-year promise to repeal the Affordable Care Act.

3 Republicans and 48 Democrats let the American people down. As I said from the beginning, let ObamaCare implode, then deal. Watch! — Donald J. Trump (@realDonaldTrump) July 28, 2017

The Senate has tried to pass multiple versions of repeal: repeal and replace, a straight repeal and Friday's bare-bones repeal, but none garnered the support of 50 Republicans.

An emotional Senate Majority Leader Mitch McConnell, R-Ky., said after the 1:40 a.m. vote went down that Republicans remained committed to repealing the Obama-era health law.

“We told our constituents we would vote that way and when the moment came, the moment came, most of us did," he said.

"This is clearly a disappointment," McConnell added. "It's time to move on."

The return of McCain to Washington after a brain cancer diagnosis added drama to the already tense proceedings. It was his vote — the 50th — that allowed Republicans begin debating the measure.

McCain gave a heartfelt speech upon his return to the Senate on Tuesday, decrying the rise of partisanship. And it was McCain who put an end to the partisan repeal effort.

McCain spoke to Trump last night on the phone and the president urged him to vote to for the “skinny repeal” bill — assuring him it wouldn’t end up passing into law, according to one source with direct knowledge of the call.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Vice President Mike Pence, who arrived in the chamber in a bid to rescue the bill and in preparation to cast the deciding vote, stood alongside McCain's desk and then joined the senator in the cloakroom. By the time they re-emerged, separately, the vote had begun.

McCain went back to his desk and sat after casting his "no" vote. He eventually made his way to the Democrats' side of the chamber and was greeted with hugs and cheers.

"I believe each of us stood up for the reasons that we felt were right"

Several Republicans said they did not know where McCain would fall, and there were audible gasps in the chamber when he turned down his thumb to indicate his decision.

The renowned maverick had committed perhaps his most rebellious move ever, defying his party and president on the one issue that had united the Republicans for nearly a decade.

He walked off the Senate floor saying little. “I thought it was the right vote,” he said a short time later while getting into his car.

Soon after his office put out a more thorough statement:

"I’ve stated time and time again that one of the major failures of Obamacare was that it was rammed through Congress by Democrats on a strict-party line basis without a single Republican vote. We should not make the mistakes of the past that has led to Obamacare’s collapse, including in my home state of Arizona where premiums are skyrocketing and health care providers are fleeing the marketplace."

It isn't clear what comes next, but the collapse of some insurance markets around the country serve as an incentive for Republicans and Democrats to hold hearings and fix the problems with health care.

Most Republicans never embraced the different iterations of legislation they crafted, nor the process by which it was constructed. Even on the last-ditch effort at a bare-bones bill, Republicans couldn’t reach agreement. Over the past two days, many rejected a plan that would have partially repealed and replaced Obamacare and a measure that would have just repealed it. The repeal vote was the same bill that passed the Senate and the House in 2015 when former President Barack Obama vetoed it.

Sen. Lisa Murkowski, R-Alaska, stood against every version of the legislation even in the face of immense pressure. The Trump administration threatened to withhold federal resources from Alaska because of her opposition, according to the Alaska Daily News. Murkowski herself said the next day in response to the report that she would not characterize it as a "threat."

"I sat there with Senator McCain. I think both of us recognize that it’s very hard to disappoint your colleagues," Murkowski told NBC News after the vote. "And I know that there is disappointment because it was the three votes that Senator McCain, Senator Collins, and I cast that did not allow this bill to move forward. And that is difficult."

"But I believe each of us stood up for the reasons that we felt were right," she added.

The failed vote happened just three hours after the text of the latest version was released, and the slimmed-down version, designed specifically to get the 50 votes it needed, still it wasn't enough to gather the support necessary.

Democrats sustained their pressure against Republicans by slowing down not only the health care debate on the floor but all Senate activity. Activists, meanwhile, held daily protests on Capitol Hill, targeting skittish senators’ offices. Those protests continued until the vote occurred Friday morning with health care activists gathered outside the Capitol.

We are not celebrating; we are relieved--for the Americans who can now keep their #healthcare. We must work together to improve the law. — Chuck Schumer (@SenSchumer) July 28, 2017

Senate Minority Leader Chuck Schumer, D-N.Y., told reporters that he knew McCain was going to vote against his own party's bill by around 10 p.m., three hours before the vote. He said he had talked to his colleague four or five times per day over the last three days.

"John McCain is a hero and has courage and does the right thing," Schumer said.

Until the end, passage on the Health Care Freedom Act, also dubbed the “skinny” repeal, was never certain. Even Republicans who voted for it disliked the bill.

“The skinny bill as policy is a disaster. The skinny bill as a replacement for Obamacare is a fraud. The skinny bill is a vehicle to getting conference to find a replacement,” Sen. Lindsey Graham, R-S.C., said at a Thursday evening news conference hours before the vote alongside fellow Republicans McCain, Ron Johnson and Bill Cassidy, before the details were released.

The “skinny” repeal was far from Republicans’ campaign promise of also rolling back Medicaid expansion, insurance subsidies, Obamacare taxes, and insurance regulations.

Many Republicans who did vote for it said they were holding their nose to vote for it just to advance the process into negotiations with the House of Representatives.

The legislation included a repeal of the individual mandate to purchase insurance, a repeal of the employer mandate to provide insurance, a one-year defunding of Planned Parenthood, a provision giving states more flexibility to opt out of insurance regulations, and a three-year repeal of the medical device tax. It also would have increased the amount that people can contribute to Health Savings Accounts.

In the hurried process of trying to come up with legislation, the non-partisan Congressional Budget Office released an analysis late on Thursday night that found that 16 million people would lose their health insurance in 2018 under the latest plan. Premiums would have risen 20 percent each year over the next decade, the analysis found.