Sen. John McCain, a former prisoner of war who embraced patriotism loudly and religion quietly, died Saturday at age 81.

McCain was diagnosed in July 2017 with glioblastoma, an aggressive form of brain cancer.

The longtime Arizona Republican senator, reared in the Episcopal Church, attended a Southern Baptist megachurch in his later years. He viewed himself as a Christian but had “a distrust of the religious right and a faith that is too public, too political,” author Stephen Mansfield, author of books about the faiths of presidents and presidential candidates, told Religion News Service in December 2017.

It was during McCain’s runs for president, especially his second campaign in 2008, that he spoke about his faith. But, even then, he tended to tell a story about a silent expression of belief in God.

In a family memoir, a campaign ad as well as a televised interview with megachurch pastor Rick Warren, he recalled a guard in his prisoner of war camp in Vietnam who shared his faith one Christmas.

“He stood there for a minute, and with his sandal on the dirt in the courtyard, he drew a cross and he stood there,” McCain told Warren at the Saddleback Civil Forum in August of that campaign year. “And a minute later, he rubbed it out, and walked away. For a minute there, there were just two Christians worshipping together.”

Asked by Warren what being a Christian means, McCain simply replied: “It means I’m saved and forgiven.”

At the time of that campaign, McCain biographer Paul Alexander told RNS that the senator’s military and faith backgrounds were responsible for his religious reserve.

“He’s a very spiritual person but … in his core, he’s a military man,” said Alexander, author of “Man of the People: The Maverick Life and Career of John McCain.” “They don’t feel comfortable talking about religion.”

During his 5½ years in a POW camp in Vietnam, McCain drew on his Episcopal roots — his great-grandfather was an Episcopal minister and McCain attended Episcopal day and boarding schools.

In his family memoir, “Faith of My Fathers,” he recounted how he “prayed more often and more fervently than I ever had as a free man.”

George “Bud” Day, a fellow POW, said McCain was among those who volunteered to preach at religious services they were eventually permitted to hold at the prison known as the “Hanoi Hilton.”

“He was a very good preacher, much to my surprise,” Day told RNS in 2008, when he was 83. “He could remember all of the liturgy from the Episcopal services … word for word.”

Day died in 2013 and McCain spoke at his funeral.

On one Christmas in captivity, McCain recalled in the memoir, as “room chaplain” he was given a few minutes to copy passages from a Bible. Then, in between hymns sung with emotion by his comrades, he read portions of the story of the birth of Christ.

“It was more sacred to me than any service I had attended in the past,” he wrote, “or any service I have attended since.”

In recent years, McCain sometimes spoke in person and online of his reliance on prayer. He tweeted about praying for people who were victims of tragedies, from a Sutherland Springs, Texas, church to the tourist attractions of New York City.

“Prayer was the most important thing for him when he was a POW and he often mentions prayer in times of national crisis,” said Mansfield. “Otherwise, he’s been cautious about mentioning it very publicly because he does not want to be identified with the religious right or some of the more religious politicians he despises.”

McCain’s differences with some conservative Christians were prominently displayed in the 2000 campaign when he called Pat Robertson and Jerry Falwell “agents of intolerance,” remarks for which he later apologized. In a conciliatory move, McCain spoke at the 2006 commencement at Falwell’s Liberty University and, in an even greater outreach to the religious right, chose then-Alaska Gov. Sarah Palin, an anti-abortion evangelical, as his 2008 running mate.

He made an immediate defense of then-Sen. Barack Obama when a woman at a 2008 campaign appearance expressed her lack of trust in the Democratic candidate because she believed he was “an Arab.” McCain corrected her and said Obama was a “decent, family man.”

“For a few moments in his own campaign stop, he defended his opponent,” Mansfield recalled in a January 2018 interview. “He, like [Ronald] Reagan, has no problem speaking kindly of the other side and in personal terms.”

Paul Kengor, a political scientist at Grove City College in Pennsylvania, said a story about McCain’s family life demonstrated to him the kind of man McCain was. His wife, Cindy McCain, unexpectedly adopted a child with a cleft palate from an orphanage run by Mother Teresa in Bangladesh in 1991. When Cindy McCain appeared with the child at the airport when she arrived home, that was the first he knew of the decision, The Telegraph reported.