President Donald Trump and former President Barack Obama have responded to Arizona Senator John McCain's death.

McCain, a six-term U.S. senator and onetime presidential candidate, died at his home in Arizona on Saturday, one day after his family announced that he would no longer pursue treatment for his brain cancer. He was 81.

McCain, who served in the Navy, was captured during the Vietnam War when his plane was shot down in 1967. He spent five and a half years in a North Vietnam prison.

During the 2016 presidential campaign, Trump criticized McCain's military service, saying that McCain's “not a war hero. He's a war hero because he was captured. I like people who weren't captured.” Later, McCain, a Republican, dealt a blow to Republican efforts to repeal Obamacare, which Trump had much touted.

“My deepest sympathies and respect go out to the family of Senator John McCain,” Trump said in a tweet. “Our hearts and prayers are with you!”

In 2008, Obama defeated McCain to take the White House.

“Few of us have been tested the way John once was, or required to show the kind of courage that he did,” Obama said in a press release. “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. And for that, we are all in his debt.”

McCain's opposition to LGBT rights – he opposed repeal of “Don't Ask, Don't Tell” and extending marriage rights to gay and lesbian couples – lessened in recent years. He opposed an effort that sought to undermine an executive order banning discrimination against LGBT workers by federal contractors. Last year, he vocally opposed Trump's effort to bar transgender troops, saying that transgender people should be allowed to serve provided they meet the military's “medical and readiness standards.”