United States Senator John McCain, a prisoner of war in Vietnam and a two-time contender for the presidency, died on Saturday at his home in Arizona at the age of 81.
McCain had been diagnosed with a malignant brain tumor, called a glioblastoma, in 2017 and was being treated periodically with radiation and chemotherapy.
According to a statement from his office, McCain died at 4:28 pm local time.
His family had announced this week that he was discontinuing medical treatment.
The son and grandson of four-star admirals, McCain endured more than five years of imprisonment and torture by the North Vietnamese as a young naval officer.
"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, in the the place he loved best," McCain's wife Cindy McCain said in a post on Twitter.
Condolence messages poured in from across party lines on McCain's passing.
US 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!".
Former US President Barack Obama said in a statement that while McCain and he came from completely different backgrounds and competed at the highest level of politics, "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," Obama said.
Prime Minister Narendra Modi also expressed grief over the demise of McCain.
"Deeply saddened by the demise of Senator John McCain. People of India join me in sincerely condoling the loss of a steadfast friend. His statesmanship, courage, conviction and understanding of global affairs will be missed. Condolences to his family and well-wishers," Modi tweeted with a picture of himself and McCain.
During three decades of serving as Arizona Senator, McCain made two unsuccessful attempts for the presidency.
He lost a bitter primary campaign to George W Bush and the Republican establishment in 2000.
He won the nomination in 2008, only to be defeated in the general election by Obama.
Bush called his one-time political rival "man of deep conviction and a patriot of the highest order" and a "friend whom I'll deeply miss."
Former vice president Al Gore said he always admired how the senator "would work to find common ground, no matter how hard."
McCain was close friends with Senator Lindsey Graham and former senator Joe Lieberman -- a trio dubbed the "Three Amigos."
Graham wrote that "America and Freedom have lost one of her greatest champions. And I've lost one of my dearest friends and mentor." Democrat Senator Chuck Schumer hailed him as a "truth-teller" with "unsurpassed" dedication to the US and its military. He said he would seek to rename a Senate building in McCain's honour.
McCain was also a persistent critic of Obama's foreign policy.
"The demand for our leadership in the world has never been greater. People don't want less of America — they want more," McCain said in 2012. "Everywhere I go in the world, people tell me that they still have faith in America. What they want to know is whether we still have faith in ourselves."
Despite his serious health condition, McCain had appeared in the Senate to cast a thumbs-down vote against his party's drive to repeal the Affordable Care Act.
John Sidney McCain III was born August 29, 1936, in the Panama Canal Zone and into a family whose military lineage included an ancestor who served as an aide to Gen George Washington during the Revolutionary War.