WASHINGTON (AP) — Sen. John McCain appeared poised to be the savior of the GOP health bill when he returned to the Capitol earlier this week despite brain cancer.

He turned out to be the bill’s executioner.

In an astonishing development early Friday, the longtime Arizona senator turned on his party and his president, joining two other GOP senators in voting “no” on Republicans’ final effort to repeal “Obamacare.”

His unexpected vote killed the bill, and also dealt what looks like a death blow to the Republican Party’s years of promises to get rid of Barack Obama’s health law.

At 80 years old in the twilight of a remarkable career, McCain lived up to his reputation as a maverick. When he walked into the well of the Senate around 1:30 a.m. and gave a thumbs-down to the legislation, Democrats briefly broke into cheers, which Minority Leader Chuck Schumer quickly waved his arm to quiet.

Majority Leader Mitch McConnell stood stone-faced, his arms crossed. President Donald Trump later tweeted his disapproval, but a president who once mocked McCain’s years as a prisoner of war in Vietnam apparently did not have much sway on the six-term senator when it counted.

Just days earlier, on Tuesday, McCain had buoyed GOP health efforts when he returned to the Capitol for the first time after getting diagnosed with a brain tumor, and cast a decisive vote to open debate on the GOP repeal legislation. Yet even then he forecast that his support could not be counted on, as he took the floor to lecture his colleagues, the scars from his surgery etched severely along the left side of his face.

“The Obama administration and congressional Democrats shouldn’t have forced through Congress, without any opposition support, a social and economic change as massive as Obamacare. And we shouldn’t do the same with ours,” McCain said then.

“Why don’t we try the old way of legislating in the Senate, the way our rules and customs encourage us to act,” he added. “If this process ends in failure, which seems likely, then let’s return to regular order.”

The outcome McCain predicted came to pass — he made sure that it did. And now if Republicans want to get anything done on health care, they will have little choice but to return to regular order and turn to Democrats.

McCain was not the lone Republican senator in killing the health bill. Sens. Lisa Murkowski of Alaska ignored criticism and even threats from Trump and his administration to cast a “no” vote, as did Susan Collins of Maine, a moderate who has opposed GOP efforts all along.

McConnell’s remarks in the immediate aftermath of the vote were a bitter rebuke to all three.

“I and many of my colleagues did as we promised and voted to repeal this failed law,” McConnell said on the Senate floor, glaring toward the Republican side of the aisle. “We told our constituents we would vote that way and when the moment came, when the moment came, most of us did.”

McCain cast his “no” vote even though he campaigned for re-election last fall on promises to repeal and replace “Obamacare.” He did it despite heavy lobbying in the Senate chamber from Vice President Mike Pence, who was in lengthy and intense conversation with the senator right before the vote, as the president himself pushed for the legislation to pass.

And in perhaps the crowning irony, McCain’s vote saved a law that was the signal achievement of his political nemesis, Obama, who defeated him for the presidency in 2008.