US Senator John McCain, the Vietnam war hero turned senator and presidential candidate, has died aged 81.

John McCain, a proud naval aviator survived years as a prisoner of war in Vietnam and going on to become a Republican congressman, senator from Arizona and a two-time contender for presidency.

McCain, died on Saturday at 4.28 p.m. at his ranch near Sedona, Arizona, his office announced in a statement on Sunday. The son and grandson of Navy admirals, he was born on August 29, 1936, in the Panama Canal Zone.

In 2017, he was diagnosed with a tumour, called a glioblastoma, for which he had been treated periodically with radiation and chemotherapy.

John McCain
US senator John McCainReuters

His family had announced earlier this week that he was discontinuing medical treatment.

During three decades of representing Arizona in the Senate, he ran twice unsuccessfully for president, reports The Washington Post.

He lost a bitter primary campaign to George W. Bush and the Republican establishment in 2000.

McCain then returned to win the nomination in 2008, only to be defeated in the general election by Barack Obama, a charismatic Illinois Democrat who had served less than one term as a senator.

The Arizonan warrior politician, who survived plane crashes, several bouts of skin cancer and brushes with political oblivion, often seemed to be perpetually waging a race against time and his own mortality while striving to ensure that his five-and-a-half years as a Vietnam prisoner of war did not stand as the defining experience of his life.

McCain had not been in Washington since December 2017, leaving a vacuum in the corridors of the Senate and the television news studios he roamed for decades, CNN said.

In recent months, he was not completely quiet, however, blasting President Donald Trump in tweets and statements that showed while he was ailing he had lost none of his appetite for the political fight.

The Senator repeatedly made clear that he saw Trump and his "America First" ideology as a departure from the values and traditions of global leadership that he saw epitomised in the US.

McCain's most dramatic break with Trump came nine days after the Senator announced on July 19, 2017, that he had been diagnosed with brain cancer. He returned to the Senate chamber, with an incision from surgery still fresh above his left eye, and turned thumbs down on a Republican plan to replace the Affordable Care Act.

His no vote, along with those of two other Republicans, sent his party's signature legislative goal hurtling toward oblivion.

He also questioned why Trump was solicitous of Russian President Vladimir Putin, whom he regarded as an unreformed KGB apparatchik.

In one of his final public acts, he blasted Trump's cozy summit with Putin in July, blasting it as "one of the most disgraceful performances by an American president in memory".

John McCain
US Senator John McCainReuters

Obama and Bush were asked to give eulogies.

In a memoir published in May, McCain wrote that he hated to leave the world, but had no complaints.

"It's been quite a ride. I've known great passions, seen amazing wonders, fought in a war, and helped make peace," McCain wrote.

"I've lived very well and I've been deprived of all comforts. I've been as lonely as a person can be and I've enjoyed the company of heroes. I've suffered the deepest despair and experienced the highest exultation. I made a small place for myself in the story of America and the history of my times."

McCain died on Saturday surrounded by his family, according to a statement released by his office, BBC reported.

He was diagnosed with an aggressive brain tumour in July 2017 and had been undergoing medical treatment.

His family announced McCain, who left Washington in December, had decided to stop treatment on Friday.

The six-term senator and 2008 Republican presidential nominee was diagnosed after doctors discovered his tumour during surgery to remove a blood clot from above his left eye last July.

The son and grandson of Navy admirals, McCain was a fighter pilot during the Vietnam War. When his plane was shot down, he spent more than five years as a prisoner of war.

While in the custody of his captors, he suffered torture that left him with lasting disabilities.