Senate Majority Leader Mitch McConnell. J. Scott Applewhite/AP Images

Senate Republicans came out of 20 hours of debate with a stunning failure in their efforts to overhaul the US healthcare system — and Sen. John McCain of Arizona cast a decisive vote.

Early Friday morning, the Senate voted against a "skinny" plan to repeal the Affordable Care Act. Republican senators formed the last-ditch effort, called the Health Care Freedom Act, after earlier votes on the Senate's healthcare plans failed.

The vote failed, with 49 voting in favor and 51 voting against. Three Republican senators — McCain as well as Sens. Lisa Murkowski of Alaska and Susan Collins of Maine — voted no. All 48 Democrats joined them.

This vote was to replace the House bill, the American Health Care Act.

The skinny bill included a series of amendments that aimed to repeal certain unpopular parts of the Affordable Care Act.

The failure left Senate Majority Leader Mitch McConnell with no clear options moving forward. The Senate has been grappling for weeks with healthcare overhaul, running through different versions of legislation before settling on the more modest attempt with the aim of moving to a conference with the House of Representatives.

In a surreal scene on the Senate floor, McConnell and Vice President Mike Pence were seen before the vote speaking with McCain. A previous vote was left open for more than 40 minutes as it appeared Republican leaders attempted to persuade McCain, who made a dramatic return to the Senate this week after receiving a diagnosis of brain cancer, to change his vote.

In announcing his vote, McCain came to the Senate floor and put his right thumb down before walking off.

"It's time for our friends on the other side to tell us what they have in mind, and we'll see how the American people feel about their ideas," McConnell said after the vote, suggesting it was time to "move on" from healthcare.

Minority Leader Chuck Schumer said after the vote that he wanted to "turn the page" and move on to improve the ACA.

"We are not celebrating," he said. "We are relieved."

The failed vote marks the end of the road for the healthcare debate in the Senate, which had been going on since Tuesday.