US senator John McCain, the maverick Republican who survived a Vietnam War prison camp and ran unsuccessfully for president, has died at the age of 81 after struggling with an aggressive form of brain cancer.

Key points: The Republican senator had been undergoing treatment for brain cancer

The Republican senator had been undergoing treatment for brain cancer His wife Cindy and other family members were with him when he died

His wife Cindy and other family members were with him when he died Senator McCain ran for president in 2008, when he lost to Barack Obama

The six-term Republican senator had been suffering from a number of health problems in recent years.

He had also been undergoing treatment for glioblastoma, an aggressive brain cancer, since December 2017. He had previously survived the removal of non-invasive melanomas at least three times.

A statement from Senator McCain's office said his wife Cindy and other family members were with him when he died.

"At his death, he had served the United States of America faithfully for 60 years," the statement read.

US President Donald Trump, who carried out a bitter public feud with Senator McCain during his illness, expressed his sympathy in a tweet following the news of his death.

Loading

Cindy McCain paid tribute to her late husband in a message posted to Twitter, saying her heart was "broken".

Loading

Senator McCain was the Republican Party's US presidential nominee in 2008, when he and running mate Sarah Palin lost to Barack Obama.

John McCain, with wife Cindy in the background, during the 2008 presidential campaign. ( AP: Bill Sikes )

He also made a bid for the party's nomination for president in 2000, but lost to George W Bush.

Senator McCain supported Mr Trump during the 2016 presidential election but withdrew his backing on the release of an audio recording in which Mr Trump boasted about kissing and grabbing women.

McCain 'represented the best ideals' of the US

US Defence Secretary James Mattis released a statement mourning the loss of "a man who steadfastly represented the best ideals of our country".

"On behalf of all of the men and women of the Department of Defense, we will remain forever grateful for the life, the passion, and the example of Senator John McCain," he said.

Mr Obama said in a statement that although he and Senator McCain were members of different generations, and came from different backgrounds, they shared "a fidelity to something higher — the ideals for which generations of American 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," Mr Obama said in a statement.

"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."

Senator McCain's son Jack paid tribute to his father on Twitter, saying, "it is not the man that was great, but instead it was his desire to serve a cause greater than himself that defined his life".

"To me, he was a giant, but to him he was an imperfect servant of the nation he loved deeply. Fair winds, following seas, and clear skies."

Prime Minister Scott Morrison described Senator McCain "as a true friend of Australia", as he expressed sympathy for the McCain family.

Loading

Son and grandson of Navy admirals

Senator John McCain (bottom right) poses with his US Navy squadron in 1965. ( Reuters: National Archives/Handout )

John McCain was born at the Coco Solo Naval Station in Panama on August 29, 1936.

His father and paternal grandfather were both admirals in the US Navy.

He followed in their footsteps, graduating from the United States Naval Academy in Maryland in 1958.

Serving as a Navy pilot, Senator McCain was almost killed in a fire on the aircraft carrier USS Forrestal during the Vietnam War.

On his 23rd combat mission over Vietnam in 1967, his plane was shot down.

John McCain is escorted to Gia Lam Airport in Hanoi, Vietnam, after being released from captivity on March 14, 1973. ( AP: Horst Faas, file photo )

He spent five-and-half years in captivity, including two in solitary confinement, and was subjected to frequent beatings and torture.

In the Senate, he was a critic of harsh interrogation techniques such as "waterboarding" or simulated drowning.

First elected to the US House of Representatives in 1982, Senator McCain won his first term in the Senate in 1986.

Seen as a maverick in his campaign for the 2000 Republican presidential nomination, Senator McCain gave then-Texas governor George W Bush a scare by winning the first-in-the-nation primary state of New Hampshire by 18 percentage points.

Sorry, this video has expired John McCain defends his presidential opponent Barack Obama while on the campaign trail in 2008.

But he lost to Mr Bush in South Carolina after bitter state primary campaigns.

Eight years later, he fought back from the brink of defeat to win the Republican nomination, with Sarah Palin as his running mate, but lost to Mr Obama.

Frequent critic and target of President Trump

Senator McCain was a frequent critic, as well as a target, of Mr Trump.

In 2017 Senator McCain criticised the system that allowed Mr Trump to avoid service in the Vietnam War.

Sorry, this video has expired Senator McCain issued a veiled criticism of US President Donald Trump's medical deferments which kept him from serving in Vietnam. ( ABC News )

He declined to name Mr Trump a "draft dodger" but made a veiled criticism of the medical deferments that kept the US President from serving during the conflict.

While recovering from the side effects of his cancer treatment, Senator McCain maintained his public political commentary.

He denounced Mr Trump for among other things his praise of Russian President Vladimir Putin and other leaders the senator described as foreign "tyrants."

"Flattery secures his friendship, criticism his enmity," Senator McCain said of Mr Trump in his memoir, The Restless Wave, which was released in May.

Senator McCain supported investigations into the Russia hacking scandal, saying the evidence that Mr Putin sought to influence the 2016 election was conclusive.

In July he castigated Mr Trump for his summit with Mr Putin, issuing a statement that called their joint news conference in Helsinki "one of the most disgraceful performances by an American President in memory".

He said Mr Trump was "not only unable but unwilling to stand up to Putin".

Sorry, this video has expired John McCain votes against 'Obamacare' repeal

Last July, Senator McCain received a standing ovation from fellow senators when he returned to Washington shortly after his cancer diagnosis for a middle-of-the-night Senate vote.

Still bearing a black eye and scar from surgery, Senator McCain gave a thumbs-down signal in a vote to scuttle a Trump-backed bill that would have repealed the Obamacare healthcare law and increased the number of Americans without health insurance by millions.

Mr Trump was furious about Senator McCain's vote and frequently referred to it at rallies without mentioning Senator McCain by name.