With a simple thumbs down, Sen. John McCain dramatically ended Republicans’ seven-year campaign to repeal and replace the Affordable Care Act.

McCain, in the early hours of Friday morning, voted against his party’s scaled-back version of an Obamacare repeal, becoming the decisive vote preventing the GOP from succeeding on its top agenda item and throwing its legislative agenda into deep uncertainty. The Arizona Republican, along with Maine Sen. Susan Collins and Alaska Sen. Lisa Murkowski, joined all Democrats in opposing the legislation gutting key portions of the ACA. All other Republicans voted for the repeal, which failed by a tally of 51-49.

Republican senators appeared stunned walking off the floor following the vote, with several declining to comment to reporters as they departed. "Needless to say, pretty disappointed," Sen Pat Toomey said. "It’s just sad," Sen. Ron Johnson added.

Sen. Ted Cruz called it a "sad day for the American people." He also criticized his Republican colleagues who voted against the measure, essentially calling them hypocrites.

"I sadly feel a great many Americans will feel betrayed, that they were lied to. And that sentiment will not be unjustified," Cruz told reporters. "You cannot campaign against Obamacare and then vote for Obamacare. Those are inconsistent actions."

Trump tweeted his frustration shortly after the vote failed:

"3 Republicans and 48 Democrats let the American people down. As I said from the beginning, let ObamaCare implode, then deal. Watch!"

The vote came after seven years of promises to undo President Obama’s signature law and seven months of Republican legislative efforts since taking control of the government in January. There were numerous fits and starts, and deep divisions within the party made threading the needle and passing any legislation extremely difficult. Ultimately, after narrowly agreeing to debate the bill earlier this week, Republicans searched for the “least common denominator,” in their own words, hoping to find any measure of Obamacare repeal that could pass.

Even the scaled-back effort proved unsuccessful.

Majority Leader Mitch McConnell, in a somber speech after the failed vote, acknowledged defeat and thanked President Trump, Vice President Mike Pence and his fellow GOP senators for their efforts.

“This is a disappointment. A disappointment, indeed,” McConnell said, adding his thanks to House Republicans, who narrowly passed Obamacare repeal in May. “I regret that our efforts were simply not enough this time.”

McCain, for his part, downplayed his vote as he departed the Senate chamber shortly after 2 a.m.

“I thought it was the right thing to do,” he told reporters.

Later, in a statement, McCain said the legislation he voted against did not accomplish his goals of increased competition, lower costs and improved care:

“We must now return to the correct way of legislating and send the bill back to committee, hold hearings, receive input from both sides of aisle, heed the recommendations of the nation’s governors, and produce a bill that finally delivers affordable health care for the American people.”

The GOP senators opposing the measure had received a full-court press from their party. The vote was held open more than an hour longer than expected as Republicans spoke with McCain and Murkowski, pushing for a change of heart. Pence, there to cast a potential tie-breaking vote, spoke with McCain in a small group of senators for an extended period. He then spoke to him at length one-on-one on the Senate floor, and again in the private cloakroom off the chamber. Meanwhile, several members of Senate leadership spoke with Murkowski on the floor right until the moment she cast her no vote.

At one point, McCain crossed the Senate to speak with Democratic leader Chuck Schumer, and was surrounded by a crowd of Democrats, who appeared upbeat and jovial. Before the vote, he got hugs on the floor from two fellow longtime lawmakers, Democratic Sen. Dianne Feinstein and Republican Sen. Orrin Hatch.

Both Collins and Murkowski voted no before McCain, who waited until after the full roll call of senators came and went before catching the attention of the chamber and putting his thumb down. Audible gasps could be heard in the chamber as he cast the vote.

The legislation that failed was a far cry from the repeal-and-replace measure the House passed, or the repeal bill Senate Republicans passed in 2015. It would have undone key provisions of the Affordable Care Act by gutting the individual mandate, temporarily removing the employer health care mandate, repealing the tax on medical devices and defunding Planned Parenthood for one year.

It was the simplest version of the legislation McConnell thought could pass the chamber. He unveiled it just after 10 Thursday night, and the vote was scheduled to take place shortly after midnight. After the delay to try to persuade McCain, Collins or Murkowski to sign on to the bill, the Senate voted shortly before 2 a.m.

The dramatic failure capped a suspenseful and uncertain day on Capitol Hill, with Republican senators expressing doubts in the late afternoon hours about the details of what they would vote on. Many were opposed to the policy details of the legislation, and said they were supporting it only as a means to begin a conference with the House, hoping the two chambers could craft something that could pass several weeks down the road. Few senators were supportive of the legislation on its own, and though the vast majority ultimately backed it, many of them expressed hope that it would not become law in its current state.

McCain, along with Johnson and Sen. Lindsey Graham, held a press conference in the late afternoon signaling that they would oppose the legislation unless they received assurances from Speaker Paul Ryan that the House would not simply pass the legislation and send it to Trump to sign.

Graham called the repeal bill “woefully inadequate” in the afternoon, and later called it “terrible” and a “fraud.” Others shared the sentiment. The Congressional Budget Office predicted that the legislation would have caused 16 million fewer people to have health insurance next year, and for health insurance premiums to rise by 20 percent.

Ryan ultimately gave an assurance. He put out a statement in the early evening saying that going to conference was “something that the House is willing to do.” But he also made clear that Senate Republicans needed to prove they could pass a comprehensive replacement plan, which the House had already done, and he gave no guarantee that the plan before the Senate would never come up for a vote in the lower chamber. There was frustration among House Republicans, according to aides, that the Senate was asking for assurances when they had yet to pass a bill. Ryan later spoke to five senators -- though notably not McCain -- on speakerphone in Sen. John Cornyn’s office just off the Senate floor to repeat his guarantee that the bill would go to conference. His assurances convinced all five to support the legislation.

“This is something we’ve got to move on. That’s why I’m taking a chance on this skinny bill,” said Sen. David Perdue, who shared the group of five’s concerns but was not part of the call with Ryan. “I would not want the skinny bill to be the law of the land. The only reason I’m voting on it is as a vehicle to get to conference.”

After the five senators came out in favor of the GOP plan, most eyes in the Senate turned to McCain as the likeliest lawmaker left to oppose it -- Collins and Murkowski, who earlier in the week voted against debating the legislation, were expected to oppose it. At that point, however, McCain’s position was not clear. Even Graham, McCain’s closest friend in the Senate, appeared uncertain.

“I think John is rightfully upset with the process, and whatever he does, he’s earned the right to do it,” he told reporters well before the vote.

Democrats, hoping to persuade McCain to vote no, cited the Arizona Republican’s speech on the Senate floor Tuesday where he criticized the process and product of his party’s health care efforts, and predicted that it would fail.

After the vote, Democrats sang his praises.

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

McConnell, in his speech after the failed vote, said that Democrats had refused to engage “in a serious way” on repealing the law, and challenged them to put forward health care legislation. He said he would not support “bailing out insurance companies” without other reforms.

“I suspect there are not many folks over here that are interested in that. But it’ll be interesting to see what they have in mind,” McConnell said.

Still, Republicans and Democrats have said for weeks that if the GOP repeal effort failed, there would likely be bipartisan movement on health care legislation. Sen. Lamar Alexander, the chairman of the health committee, said earlier this month he would hold hearings on health care regardless of the outcome of the repeal effort.

Schumer, in a speech on the floor following the vote, said Democrats were celebrating, but relieved.

“Obamacare was hardly perfect. It did a lot of good things, but it needs improvement,” he said. “I hope that one part of turning that page is that we go back to regular order, work in the committees together to improve Obamacare.”