FILE - In this Feb. 23, 2009, file photo, Sen. John McCain, R-Ariz. listens during remarks of the Fiscal Responsibility Summit, hosted by President Barack Obama in the East Room of the White House in Washington. Longtime friends and advisers of McCain say they’re not surprised by his decision in September 2017 to oppose a last-ditch Republican effort to overhaul the nation’s health care law. McCain objected to the legislation in part because Senate GOP leaders wanted a vote without holding hearings or debate.(AP Photo/Charles Dharapak, file)

WASHINGTON (AP) — John McCain faced a choice that balanced friendship, party loyalty and his convictions. He made the decision some of his closest advisers expected.

Looking at the twilight of his career and a grim cancer diagnosis, the Republican senator from Arizona who prides himself on an independent streak could not be moved to go along with a last-ditch GOP push to overhaul the nation’s health care system.

Those close to him say he wrestled with the choice — the legislation was championed by his best friend in the Senate — but rarely strayed from his intention to send a message to the institution where he’s spent three decades.

That message was bipartisanship and what he cast as the integrity of the Senate process that insists on debate and often yields compromise. The call for “regular order” isn’t the stuff of campaign bumper stickers, but it has become McCain’s mission since he’s returned to Washington, to keep up his work and treatment for an often fatal brain tumor.

“If he supported this, then he guts his whole message that he’s been trying to give his colleagues, both Democrats and Republicans,” said Rick Davis, who managed McCain’s two presidential campaigns and remains close to the lawmaker.

Davis said Sen. Lindsay Graham, R-S.C., “made his pitch” to his longtime friend, but McCain was motivated by “his drive to move the Senate toward more comity and bipartisanship.”

McCain’s decision probably will kill the bill and crush the GOP’s hopes for repealing the Obama health law this year. Republicans have tried to go it alone in overhauling the Affordable Care Act, speeding two attempts at passage along with minimal hearings and debate.

McCain’s statement declaring his opposition to the legislation Friday was the second time he derailed the effort.

In July, bearing a fresh surgery scar over his left eye, McCain scolded lawmakers from the Senate floor. Incremental progress isn’t glamorous or exciting, and it can be “less satisfying than winning,” said the man who won his party’s nomination but lost the White House in 2008. He struck a similar tone on Friday in a written statement, saying he believed “we could do better working together, Republicans and Democrats, and have not yet really tried.”

That McCain is well enough to play this central figure in the Republican health care efforts is a surprise to many given the gravity of his diagnosis. He announced this summer that he had an aggressive and usually fatal tumor called glioblastoma, the same type of tumor that killed Sen. Edward M. Kennedy, D-Mass., in 2009 and Beau Biden, son of then-Vice President Joe Biden, in 2015.

Biden is among the many longtime colleagues who has been in touch with McCain since his diagnosis, and the two are scheduled to reunite next month, when Biden presents the senator with the National Constitution Center’s Liberty Medal.

McCain has privately bristled at his return to Washington being covered like a melodrama, and his friends have steadfastly tried to avoid treating him like a man nearing the end of his life. When McCain’s children and some colleagues flocked to his Arizona ranch this summer, the mood was upbeat and the senator often joined his guests for hikes.

“What this man has been through in his life gives him a very calm and reasoned attitude toward death,” said Charlie Black, a veteran McCain adviser. “He believes he’s escaped it many times and maybe will again.”

Persevering against seemingly insurmountable odds has been a constant in McCain’s life and shaped his political career.

As a Navy pilot, McCain survived a fire that killed 134 sailors aboard the aircraft carrier USS Forrestal in the Gulf of Tonkin during the Vietnam War. He was captured after his plane was shot down during a bombing mission over Hanoi and spent five years as a prisoner of war, refusing early release. Later in life, he survived several bouts with melanoma, a dangerous skin cancer.

McCain, his staff and his family have made some adjustments to account for his desire to work through his illness.

After finishing his first round of radiation and chemotherapy this summer at the Mayo Clinic in Phoenix, McCain and his wife Cindy decided to decamp to Washington, moving the senator’s treatment to the National Institutes of Health. He’s undergoing a second round of therapies now and spends weekends in the nation’s capital rather than returning to Arizona.

Friends notice that the 81-year-old tires more easily in the afternoon, and his staff tries to front-load his schedule most days, a challenge in the sometimes nocturnal Senate. But friends and advisers say the senator is committed to keeping up as much of a regular schedule as possible while Congress is in session. As chairman of the Senate Armed Services Committee, he stays in regular touch with top administration officials, including national security adviser H.R. McMaster and Defense Secretary Jim Mattis.

“The citizens of Arizona are getting their money’s worth,” said Steve Duprey, a friend of the senator.