WASHINGTON (Reuters) - In the end, it was a simple hand gesture - Senator John McCain pointing his right index finger in a downward motion to register a no vote - that ruined his party’s seven-year effort to repeal Obamacare.

Senator John McCain (R-AZ) looks on during a press conference about his resistance to the so-called "Skinny Repeal" of the Affordable Care Act on Capitol Hill in Washington, U.S., July 27, 2017. REUTERS/Aaron P. Bernstein

But in that signal in the early hours of Friday, the 80-year-old McCain also delivered a political gut-punch to U.S. President Donald Trump, a fellow Republican and a man he has clashed with repeatedly over the past two years.

McCain, who just last week was diagnosed with an aggressive brain cancer, dropped a hint on Tuesday that if his legislative demands were not met he was prepared to take on Trump in the dispute over how to replace parts of Obamacare with a Republican healthcare program.

“We are not the president’s subordinates. We are his equals,” he said in an emotional speech to the Senate - his first since being diagnosed.

McCain’s relations with Trump have been frosty for some time. At an election campaign appearance in Iowa in 2015, Trump responded to criticism from McCain by denigrating the senator’s military service, which included 5 1/2-years as a prisoner of war in North Vietnam. He was tortured while in captivity and is seen as a war hero by many Americans.

“He’s not a war hero,” Trump told a gathering of religious conservatives. “He was a war hero because he was captured. I like people who weren’t captured.”

The following day, Trump said McCain’s work on behalf of military veterans was “all talk no action.”

McCain, a leading Republican voice on defense and security, has generally been restrained in his criticism of Trump but has also at times let loose, including recent accusations that Trump has weakened America’s standing in world affairs and kowtowed to Russian President Vladimir Putin.

With his Friday vote that brought the tally to 51-49 against a Republican bill repealing parts of former President Barack Obama’s Affordable Care Act, McCain became the third Senate Republican to bolt, leaving no path for passage of the measure.

The Arizona Republican, who was the Republican presidential candidate in 2008, also added another important chapter to his maverick, 30-year Senate career, stunning some of his fellow legislators and leaving Senate Majority Leader Mitch McConnell with the worst defeat of his long political career.

But most notably, McCain denied Trump what could have been the first major legislative victory of his administration, and demonstrated to the businessman-turned-president that Washington works in different ways from companies where CEOs have freer hands in dictating outcomes.

Although Trump was minimally involved in the process of crafting the legislation, he had made plain it was a priority. When the Senate failed to push through bills drawn up by the Republican leadership over the past few weeks, Trump told Republicans to get back to work and try again. He has been publicly urging them to get the job done.

PENCE OFFENSIVE FAILS

Despite McCain’s tensions with the White House, Vice President Mike Pence was assigned the task of trying to convince him to vote for the so-called skinny bill that aimed to pare away parts of Obamacare. That, after it became apparent that Trump’s cheerleading tweet on Thursday night was not working: “Go Republican Senators, Go! Get there after waiting for 7 years. Give America great healthcare!”

Pence spent 21 minutes, according to reporters watching inside the Senate chamber, talking to McCain on the Senate floor.

McCain was not budging, even after taking a short phone call from the president.

After the Senate vote tally was announced in the Senate, McCain was embraced by senators from both sides of the aisle.

Democrats were delighted he had helped kill the Obamacare repeal effort and some Republicans just wanted to show their respect for the man.

McConnell spoke bitterly of the defeat. “I imagine many of our colleagues on the other side are celebrating, probably pretty happy about all of this.”

Senate Democratic leader Chuck Schumer again called for bipartisan work to fix Obamacare’s shortcomings, saying, “I would suggest we turn the page... We are not celebrating. We are relieved.”

Just three days ago, Trump praised McCain as a brave “American hero” for coming back to Washington from Arizona, where he had been recuperating from surgery, to take part in the healthcare legislative effort.

Now the president was dejected.

“3 Republicans and 48 Democrats let the American people down. As I said from the beginning, let ObamaCare implode, then deal. Watch!,” Trump tweeted following his defeat.

On Friday, McCain advised a much different approach: an immediate, collaborative effort with Democrats on healthcare.

For McCain, who also hoped to shepherd a major defense bill through the Senate, his political and legislative tussles could now be interrupted by the more pressing need to treat his cancer.