“With the Senator when he passed were his wife Cindy and their family,” McCain’s office said in a statement.

U.S. Republican presidential nominee Senator McCain listens at campaign rally in Colorado Springs

John McCain, who shed a playboy image in his youth to become a fighter pilot, revered prisoner of war and both an independent voice in the Republican Party and its 2008 presidential nominee, died on Saturday, little more than a year after he was told he had brain cancer. He was 81.

McCain’s office said in a statement “Senator John Sidney McCain III died at 4:28 p.m. on August 25, 2018.” He announced on July 19, 2017, that he had been diagnosed with a glioblastoma, an aggressive type of brain tumor. On Friday his family announced he was discontinuing treatment.

“With the Senator when he passed were his wife Cindy and their family. At his death, he had served the United States of America faithfully for sixty years,” McCain’s office said in the statement.

His daughter, Meghan McCain, said in a statement that “I was with my father at his end, as he was with me at my beginning.”

“All that I am is thanks to him. Now that he is gone, the task of my lifetime is to live up to his example, his expectations, and his love,” she said.

McCain’s wife, Cindy McCain, tweeted: “My heart is broken. I am so lucky to have lived the adventure of loving this incredible man for 38 years. He passed the way he lived, on his own terms, surrounded by the people he loved.” She said he died in “the place he loved best.”

In his 36 years in Congress, McCain became one of the country’s most respected and influential politicians, challenging his fellow lawmakers to reach across the aisle for the good of the country, and often sparring with reporters with a biting if self-deprecating wit.

On a variety of issues — torture, immigration, campaign finance, the Iraq War — McCain was often known as the moral center of the Senate and of the Republican Party.

Last year, in his last act of defiance, McCain returned to the Capitol less than a week after his cancer was diagnosed to cast his vote on the Republican effort to repeal the Affordable Care Act — the biggest legislative achievement of President Barack Obama, the man who defeated him in the 2008 election.

McCain first voted in favor of debating the bill, giving his fellow Republicans hope that their long-sought goal of repealing Obamacare was in sight. McCain then dashed those hopes by casting the decisive vote against repeal.

Before the vote, McCain denounced the rise of partisanship in a heartfelt speech from the Senate floor on July 25, 2017.

“Why don’t we try the old way of legislating in the Senate, the way our rules and customs encourage us to act?” McCain said. “Merely preventing your political opponents from doing what they want isn’t the most inspiring work.”

But in recent months, the man who had been a mainstay on Capitol Hill for more than three decades was noticeably absent.

He missed a White House ceremony on Dec. 12, 2017, in which President Donald Trump signed the annual defense bill into law — one of McCain’s signature achievements.

A statement issued the following day by the senator’s office said he was at the Walter Reed National Military Medical Center in Maryland receiving treatment for the “normal side effects of his ongoing cancer therapy” and looked forward to returning to work as soon as possible.

McCain’s life was punctuated by wild highs and lows, from the horrific conditions he endured for nearly 2,000 days as a prisoner of war to subsequent professional successes that brought him to the forefront of American politics.

Over the course of his career he rallied against pork-barrel spending and went against his own party’s president, George W. Bush, on strategy for the Iraq war. He earned a reputation as a party maverick by advocating campaign finance reform, lending his name to the bipartisan McCain-Feingold Act of 2002, and supporting overhauling the nation’s immigration system over the years.

Image: Senators Debate Health Care Bill On Capitol Hill
Sen. John McCain (R-AZ) leaves the the Senate chamber at the U.S. Capitol after voting on the GOP ‘Skinny Repeal’ health care bill on July 28, 2017 in Washington, DC.Justin Sullivan / Getty Images

Bush said in a statement Saturday: “Some lives are so vivid, it is difficult to imagine them ended. Some voices are so vibrant, it is hard to think of them stilled. John McCain was a man of deep conviction and a patriot of the highest order. He was a public servant in the finest traditions of our country. And to me, he was a friend whom I’ll deeply miss,” and he and Laura Bush expressed their condolences to the McCain family.

The pinnacle of McCain’s political career came in 2008, when he clinched the Republican nomination for president, only to lose to Obama amid the global financial meltdown and dragged down by Bush’s low approval ratings. His contentious choice for a running mate, Sarah Palin, the governor of Alaska at the time, was also believed to have contributed to the loss, and is still seen by some as a tarnish on his reputation.

But long before then, McCain was a Navy brat who had little interest in being studious.

John Sidney McCain III was born on Aug. 29, 1936, to a prominent naval family steeped in patriotism. Both his father and grandfather were four-star admirals, with his father, John McCain Jr., advancing to commander in chief of Pacific forces during the Vietnam War.

While McCain followed in his family’s military footsteps, he did so with his own flair: When he graduated from the Naval Academy at Annapolis in 1958, he was ranked 894th of 899 graduates.

In a speech to midshipmen at his alma mater in October 2017, McCain joked about his abysmal academic performance.

“My superiors didn’t hold me in very high esteem in those days,” he said. “To be honest, I wasn’t too thrilled to be here back then, and I was as relieved to graduate — fifth from the bottom of my class — as the Naval Academy was to see me go.”

After graduation, McCain volunteered for combat duty in the Vietnam War and, as a lieutenant commander, got orders to ship out in 1967. He narrowly escaped death in July of that year, when, while preparing for a routine bombing mission, an explosion on the aircraft carrier USS Forrestal engulfed his plane in flames, killing 134 men on board.

Only three months later, on Oct. 26, 1967, McCain’s plane was shot down over North Vietnam. Both of his arms and his knee were broken, and McCain was knocked unconscious and taken as a prisoner of war.

That began a five-and-a-half-year nightmare inside a prison where Vietnamese soldiers, upon learning that McCain was the son of an admiral, set out to use him for propaganda purposes. They tortured and beat him, but McCain refused an early release, denying communist North Vietnam a propaganda victory, and followed a code of conduct that POWs must be released in the order they were captured.

When the war ended in 1973, McCain finally returned to a hero’s welcome.

In 2008, he spoke passionately about the patriotism he maintained while imprisoned in Hanoi.

“I fell in love with my country when I was a prisoner in someone else’s,” he said in accepting the Republican presidential nomination.

Obama on Saturday said in a statement: “John McCain and I were members of different generations, came from completely different backgrounds, and competed at the highest level of politics. 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.”

“Few of us have been tested the way John once was, or required to show the kind of courage that he did. But all of us can aspire to the courage to put the greater good above our own. At John’s best, he showed us what that means. And for that, we are all in his debt,” Obama said.

President Donald Trump tweeted: “My deepest sympathies and respect go out to the family of Senator John McCain. Our hearts and prayers are with you!”

McCain was first elected to office in 1982, when he won a seat in the U.S. House of Representatives from Arizona. Four years later he was elected to the Senate, and he was re-elected five times.

He first ran for president in 2000, becoming the main GOP challenger to George W. Bush, who went on to win the nomination and the White House.

In October, he reflected on his life in an interview with GQ Magazine.

“I have had the most fortunate life of anybody you will ever talk to, and I have nothing but gratitude, gratitude and joy, because I’ve had the most fortunate life that anybody has ever had,” he said. “So I spend my time in gratitude and work as hard as I can to get done what I can get done while I can.”