Senator John McCain, a former Republican presidential nominee and prisoner of war, has died after a battle with an aggressive form of brain cancer just days before his 82nd birthday.

John Sidney McCain III, 81, was the son and grandson of Navy admirals. He was born August 29, 1936.

As a naval pilot, he narrowly escaped death in a fire aboard the USS Forrestal in 1967.

TIMELINE: The life of Senator John McCain

Also in 1967, McCain's plane was shot down over Hanoi, Vietnam, and he was captured by North Vietnamese troops. He was tortured for more than five years as a prisoner of war.

After resettling in Arizona, McCain ran for Congress in 1982. He was called carpetbagger, but won the U.S. House seat anyway. After two terms, he was elected to the U.S. Senate, succeeding Barry Goldwater.

RELATED: 10 big political moments in John McCain’s life

McCain married Cindy Hensley, his second wife, in 1980. She is the daughter of a Valley beer distributor. McCain fathered seven children, including Bridget, a girl adopted from Bangladesh. Another daughter, Meghan McCain, is a television host and blogger.

A low point in his political career was when McCain was implicated in the Keating Five campaign contribution scandal. The senator emerged with a new passion to reform money in politics. Called a maverick, he bucked his party as he worked with Democrats on campaign finance and other issues.

GALLERY: 50 photos that capture John McCain's personality

McCain campaigned for president in 2000 and 2008. In 2008, he won the Republican nomination with a surprising choice of running mate: then-Alaska Gov. Sarah Palin. McCain lost in the general election to Democrat Barack Obama. In 2000, McCain rode his Straight Talk Express bus as he campaigned, and George W. Bush ultimately won the nomination.

After the second failed presidential bid, McCain continued as senator, assuming the role of an elder statesman. He visited troops overseas and dug into foreign policy.

Due to the lasting impacts of his torture as a prisoner of war, McCain could not lift his arms above his head. He had other health scares, including bouts of skin cancer that left a large scar on his cheek. In July 2017, Sen. McCain was diagnosed with glioblastoma, a deadly brain cancer. The McCain family announced that he chose to discontinue medical treatment just a day before his passing.

RELATED: What happens to John McCain's Senate seat?

Even in his waning days, McCain lived up to his reputation as a maverick. In August 2017, less than two weeks after surgery to remove his tumor, McCain returned to the U.S. Senate floor to become the deciding "no" vote on repealing Obamacare.

RELATED: Reactions to Sen. McCain's passing