John S. McCain III, an American hero who served as a United States Navy captain and a member of Congress for a combined six decades, died on Saturday, his office announced. He was 81.

McCain was a giant of the United States Senate and a lifelong public servant who won respect and admiration from his colleagues on Capitol Hill and from world leaders for his staunch advocacy of democratic principles and his defiant policy positions, particularly on issues relating to the military and national security.

He was a tough and, at times, feisty and brash legislator, but he forged friendships and bonds that cemented his place in history as a dealmaker. McCain was an institutionalist who often refused to descend into partisanship even when it may have been politically expedient. His political opponents sometimes branded him a war-monger and a reactionary at worst but never questioned his unwavering adherence to his principles, his tireless support for American troops, and his enduring commitment to public service.

“He was a great fire who burned bright, and we lived in his light and warmth for so very long,” McCain’s daughter, Meghan, wrote on Saturday night. “We know that his flame lives on, in each of us.”

The “maverick,” as he was known, was diagnosed last July with brain cancer after doctors discovered an aggressive tumor known as glioblastoma while performing an operation to remove a blood clot. Last year, McCain was undergoing regular treatment at the National Institutes of Health outside Washington while keeping up with his duties on Capitol Hill.

In December, McCain’s office said the senator was being treated at Walter Reed Medical Center for “normal side effects of his ongoing cancer therapy.” McCain had not returned to the Senate since December, opting instead to continue receiving treatment at home in Arizona.

McCain’s condition had deteriorated during the latter part of last year, and he became increasingly frail. In November, he tore his Achilles’ tendon and was forced to wear a walking boot on his lower leg and use a cane as he traversed the halls of the Capitol. Eventually he was confined to a wheelchair. And in April, McCain had surgery to treat an intestinal infection. On Friday, McCain’s family said he had stopped receiving treatment, writing in a statement that “the progress of disease and the inexorable advance of age render their verdict.” Earlier in life, he survived melanoma, a type of skin cancer.

McCain entered the Navy in 1958 at age 22, and two years later he was certified as a naval pilot. In 1967, a missile shot down his Skyhawk dive bomber over North Vietnam. He was held there as a prisoner of war at the so-called Hanoi Hilton prison for more than five years, two of them in solitary confinement.

The North Vietnamese offered to release McCain after his father, John McCain Jr., was appointed as chief of U.S. forces in the Pacific—but he twice refused, demanding that all POWs be released along with him. He believed the effort would play into the hands of the enemy by giving them a propaganda victory. Throughout his captivity, McCain was routinely tortured and tried to commit suicide several times. He was released in 1973 and went on to receive several military honors, including two Purple Hearts.

His personal experiences with torture led him to oppose the so-called enhanced interrogation techniques employed by the CIA during the Bush-era war on terror. One of his final speeches on the Senate floor was a blistering rebuke of a Trump administration nominee who helped devise the legal justification for the use of torture during the George W. Bush administration.

“This is a dark, dark chapter in the history of the United States Senate,” McCain said in the Nov. 14 address. “We are harming the commitment that our forefathers made that we are all created equal. And unfortunately we have now betrayed that sacred trust.”

Even while he was home in Arizona receiving medical treatment for the past eight months, McCain remained engaged in his work and continued to comment on the news of the day.

He urged his colleagues to reject Gina Haspel’s nomination to be CIA director, citing her involvement in the agency’s torture program and her supervision of a CIA “black site” in Thailand in 2002. Haspel was confirmed 54 to 45, but several senators cited McCain’s opposition in justifying their votes against her nomination.

McCain was among the leading Republican critics of President Donald Trump, particularly in the foreign-policy realm. After Trump met with North Korean leader Kim Jong Un in Singapore, McCain said Trump made “unnecessary and unreciprocated concessions.” And when Trump sided with Russian President Vladimir Putin’s denials of election-meddling over the assessments of his own intelligence agencies, McCain lamented that moment as “one of the most disgraceful performances by an American president in memory.”

McCain’s first run for political office came in 1982, a year after retiring from the Navy as a captain. That year, he was elected to the U.S. House of Representatives for Arizona’s 1st congressional district. He served two two-year terms before running for the U.S. Senate—and winning—in 1986. When he died, McCain was serving in his sixth term. He was re-elected in 2016.

McCain was a perpetual driving force in national politics since the turn of the century. In 2000, he mounted his first presidential bid, losing in a bruising Republican primary to George W. Bush. He would go on to support Bush’s war efforts in Iraq and Afghanistan following the Sept. 11 terror attacks.

McCain won the Republican presidential nomination in 2008, running a campaign that kept him mostly in line with Bush, whose popularity was waning. In a controversial move, McCain chose then-Alaska Gov. Sarah Palin to be his running mate that year. He lost to Barack Obama.

In his recently published book, The Restless Wave: Good times, Just Causes, Great Fights, and Other Appreciations, McCain wrote that he regretted having chosen Palin. In the early stages of the 2008 campaign, McCain had decided he would choose his close friend, former Sen. Joe Lieberman, a Connecticut Democrat-turned-independent. His campaign advisers successfully convinced him to reverse course.

“But my gut told me to ignore [that advice], and I wished I had,” McCain writes. “America's security and standing in the world were my principal concerns and the main reason, other than personal ambition, that I ran for President. Joe and I share those priorities, and on most related issues we agree on how best to serve them. I completely trusted, liked, and worked well with Joe.”

No matter how polarized the political climate had become, McCain never hit his political opponents below the belt—even when doing so might carry great political benefits. McCain won praise when, during a town hall event in 2008, he pushed back against voters who suggested that Obama represented an existential threat to America.

“I want to be president of the United States and obviously I do not want Sen. Obama to be. But I have to tell you, he is a decent person and a person that you do not have to be scared of as president of the United States,” he said to the crowd, which booed in response.

After another voter called Obama an “Arab,” McCain shook his head and took the mic from her.

“No, ma’am. He’s a decent family man, citizen, that I just happen to have disagreements with on fundamental issues. And that’s what this campaign is all about. He’s not. Thank you,” he said.

In a statement Saturday night, Obama praised McCain’s “courage to put the greater good above our own.”

“John McCain and I were members of different generations, came from completely different backgrounds, and competed at the highest level of politics,” the former president said. “But we shared, for all our differences, a fidelity to something higher—the ideals for which generations of Americans and immigrants alike have fought, marched, and sacrificed.”

McCain’s legislative accomplishments include the Bipartisan Campaign Reform Act, a campaign-finance bill he crafted with Sen. Russ Feingold (D-WI) in 2002. He worked alongside Sen. Ted Kennedy (D-MA)—with whom he had a close personal friendship—on comprehensive immigration reform, but those efforts never made it out of Congress. Earlier this year, he crafted a bipartisan immigration proposal with Sen. Chris Coons (D-DE), even as he remained at home in Arizona. That bill failed to clear the requisite 60 votes.

McCain was harshly critical of Obama’s decision to withdraw U.S. troops from Iraq at the end of 2011, warning that it would create a vacuum soon to be filled by terrorist groups. He reiterated those criticisms in 2014 when ISIS began taking control of Iraqi cities and regions.

For decades, McCain was arguably the Senate’s most influential defense hawk. In 2015, he became the chairman of the Senate Armed Services Committee, a position that allowed him to lead yearly negotiations on the National Defense Authorization Act, the annual defense appropriations bill. McCain often clashed with Democrats and dovish lawmakers from within his own party who argued that military spending had ballooned to unsustainable levels.

More recently, McCain often used his perch as chairman of the Armed Services Committee to wield influence over the Trump administration. When the Pentagon did not sufficiently explain the ambush attack in Niger that resulted in the deaths of four American troops last October, McCain threatened to block the administration’s nominees to key defense and national security positions until the committee received greater cooperation.

The senator also gained a reputation over the years as a Russia hawk, especially in recent months amid investigations into Russia’s efforts to interfere in the 2016 presidential election. He joined forces with Sen. Ben Cardin (D-MD), who was serving as the ranking member of the Senate Foreign Relations Committee, to demand answers from the administration on why it was slow-walking the implementation of new sanctions against Russia. And he slammed Trump for having congratulated Putin on his re-election, saying in a statement that Trump “insulted every Russian citizen.”

Even in his final days, McCain was pushing hard to ensure that the military would be adequately funded—a crusade that, over time, became a hallmark of his career. When Congress was recently approving a string of short-term stopgap measures to fund the government instead of coming together on a longer-term bipartisan spending package, McCain lamented that Congress was abdicating its duty to American servicemembers.

“We have cut and cut and cut to the point where we have accidents where our service members are killed and wounded because we refuse to give them what they need to defend the nation. It’s a crime,” a frustrated McCain told The Daily Beast in November.

Earlier this month, McCain’s push for increases in defense spending was successful when the new National Defense Authorization Act was signed into law. In May, the House and Senate armed services committees named the legislation after McCain.

It was always clear to McCain’s colleagues and to the general public what his priorities were. But he rarely publicized his thinking on key Senate votes ahead of time, leaving everyone wondering what he would end up deciding.

McCain again made history in July when he cast the deciding vote, in dramatic fashion, against Senate Republicans’ bill to repeal the Affordable Care Act. The vote occurred the week McCain returned to Washington following his brain cancer diagnosis, and after he delivered a blistering floor speech criticizing his colleagues for not using the Senate’s regular procedures in crafting health-care legislation—that is, trying to push it over the finish line using only the votes of one party, and rushing the process rather than holding hearings to craft a bipartisan product.

“What have we to lose by trying to work together to find those solutions? We’re not getting much done apart. I don’t think any of us feels very proud of our incapacity. Merely preventing your political opponents from doing what they want isn’t the most inspiring work,” McCain said to applause from his colleagues. “There’s greater satisfaction in respecting our differences but not letting them prevent agreements that don’t require abandonment of core principles, agreements made in good faith that help improve lives and protect the American people.”

In his book, The Restless Wave, McCain revealed that Obama called him to thank him for voting against the bill that would have repealed his signature legislative achievement.

“I appreciated his call, but, as I said, my purpose hadn’t been to preserve his signature accomplishment but to insist on a better alternative, and to give the Senate an opportunity to work together to find one,” McCain wrote.

In recent months, McCain won over the admiration of Democrats and liberals in part for his harsh criticisms of Trump, who once said that McCain was “not a war hero.” During a speech at the U.S. Naval Academy in October, McCain delivered a thinly veiled rebuke of Trump, decrying “crackpot conspiracy theories,” “protectionism,” “nativism,” and “ethnic grievances.”

In a separate speech in October, McCain condemned “half-baked, spurious nationalism cooked up by people who would rather find scapegoats than solve problems,” calling it “as unpatriotic as an attachment to any other tired dogma of the past that Americans consigned to the ash heap of history.” It was widely believed that McCain was directing his words at Trump.

In The Restless Wave, he confronted the president’s convictions more directly, writing that Trump’s “lack of empathy for refugees, innocent, persecuted, desperate men, women, and children, is disturbing.” To Trump, McCain writes, “the appearance of toughness, or a reality show facsimile of toughness, seems to matter more than any of our values.”

McCain also penned a Washington Post op-ed in which he criticized the president for his continuous war on the news media, arguing that his attempts to discredit journalists embolden dictators worldwide. The senator had a deep respect for the press as an American institution, and he always made time to take questions from reporters in the Capitol.

“While administration officials often condemn violence against reporters abroad, Trump continues his unrelenting attacks on the integrity of American journalists and news outlets,” McCain wrote in the January op-ed. “This has provided cover for repressive regimes to follow suit.”

Meghan McCain, the senator’s daughter, decided to move up her wedding—which took place last November—as a result of her father’s cancer diagnosis. Former Vice President Joe Biden, who lost his son Beau to brain cancer in 2015, appeared on ABC’s The View and consoled McCain, a co-host of the show.

“One of the things that gave Beau courage—my word—was John. You may remember when you were a little kid, your dad took care of my Beau,” Biden said in an emotional moment. “Your dad... became friends with Beau. And Beau talked about your dad’s courage—not about illness—but about his courage.”