U.S. Sen. John McCain, a war hero who survived five years as a prisoner of war in Vietnam, served three decades in Congress and went on to become the Republican Party’s nominee for president in 2008, died Saturday. He was 81 years old.

In his last hours, the Arizona Republican turned down further medical treatment, his family announced in a statement.

McCain was diagnosed with brain cancer in July 2017. Doctors discovered the tumor during a medical procedure to remove a blood clot from above his left eye. He remained upbeat after the diagnosis, flying back to Washington days after surgery with a large scar visible above his eye to partake in the Senate’s health care debate.

“I greatly appreciate the outpouring of support - unfortunately for my sparring partners in Congress, I'll be back soon, so stand-by!” McCain tweeted on July 20 after his diagnosis.

On Friday, his family issued a statement saying,“Last summer, Senator John McCain shared with Americans the news our family already knew: he had been diagnosed with an aggressive glioblastoma, and the prognosis was serious. In the year since, John has surpassed expectations for his survival. But the progress of disease and the inexorable advance of age render their verdict."

They added, "With his usual strength of will, he has now chosen to discontinue medical treatment."

McCain's wife, Cindy, tweeted that her "heart is broken" following her husband's death.

"I am so lucky to have lived the adventure of loving this incredible man for 38 years," she said. "He passed the way he lived, on his own terms, surrounded by the people he loved, in the the place he loved best."

The senator's daughter, Meghan, posted a heartfelt note online, in which she said the "task of [her] lifetime is to live up to [McCain's] example, his expectations, and his love."

"My father is gone, and I miss him as only an adoring daughter can," she wrote. "He was a great fire who burned bright, and we lives in his light and warmth for so very long. We know that his flame lives on, in each of us. The days and years to come will not be the same without my dad — but they will be good days, filled with life and love, because of the example he lived for us."

McCain was born in 1936 in the Panama Canal Zone, where his father was stationed in the Navy. After graduating from the Naval Academy in 1958, McCain went to Vietnam.

In 1967, his A4 Skyhawk was hit by a surface-to-air missile over Hanoi. McCain was captured by the North Vietnamese, who tortured and beat him for more than five years. He was in solitary confinement for several of those years.

“My room was fairly decent-sized - I’d say about 10 by 10,” McCain would later write. “The door was solid. There were no windows. The only ventilation came from two small holes at the top in the ceiling, about 6 inches by 4 inches. The roof was tin, and it got hot as hell in there.”

His captors offered him early release after learning his father was a notable naval officer. But McCain refused to leave before the other prisoners. He was released in 1973.

McCain’s injuries from his imprisonment were visible the rest of his life, most noticeably the restricted movement of his arms.

McCain got a taste of politics in 1976, when he served as the Navy’s liaison to the Senate.

In 1982, McCain was elected to the House of Representatives. Only a few years later, in 1986, he won the race to replace Arizona’s conservative Sen. Barry Goldwater.

He was implicated in what became known as the Keating Five Scandal in 1989, accused with several other lawmakers of helping the owner of the Lincoln Savings and Loan, who had donated to his campaign.

McCain ran twice for president. In 2000, he ran for the Republican nomination for president, winning New Hampshire’s primary but losing the nomination to George W. Bush.

In 2008, he defeated a host of Republican candidates to win the GOP nomination for president.

He was responsible for introducing then-Alaska Gov. Sarah Palin to a national audience by tapping her as his running mate. The McCain-Palin ticket went on to lose the general election to Barack Obama, who became the country’s first black president.

For years, McCain declined to call his choice of Palin a mistake. But in his upcoming book, “The Restless Wave,” McCain reportedly writes that he regrets not choosing his friend, then-U.S. Sen. Joseph Lieberman, D-Conn., as his running mate, calling it “another mistake that I made.” Lieberman, the 2000 Democratic nominee for vice president, was an independent who caucused with Democrats.

After the 2008 loss, McCain returned to the Senate, embracing his role as chairman of the Senate Armed Services Committee.

During his last years in politics, he had a complicated relationship with President Trump, who infamously attacked McCain during the GOP primary. In May, the McCain family was offended when it was reported that Trump aide Kelly Sadler dismissed McCain's opposition to the president’s choice for CIA director by quipping during a private meeting, "It doesn't matter, he's dying anyway."

According to the New York Times, McCain has made clear to the White House he doesn’t want Trump to attend his funeral, and would instead prefer Vice President Mike Pence at a service.

McCain is survived by his wife Cindy, seven children and five grandchildren.