When Pope Francis visited the United States in 2015, his welcomer-in-chief was then-Vice President Joe Biden.

Almost wherever Francis went, Biden was there — in the White House and the Capitol, and also in sacred spaces, including at Mass at the Basilica of the National Shrine of the Immaculate Conception. Biden followed the pope from Washington to Philadelphia, leading a farewell ceremony for the visiting dignitary he has called “the single most popular figure in the world.”

This week, President Trump painted a very different picture of Biden, mocking his presumptive Democratic opponent as a man hostile to religion. “Take away your guns, take away your Second Amendment. No religion, no anything,” Trump said of Biden on Thursday. “Hurt the Bible. Hurt God. He’s against God. He’s against guns. He’s against energy, our kind of energy.”

Biden, who was the country’s first Catholic vice president and would be the first Catholic president in more than half a century, has been motivated by his faith throughout his long career in politics.

Although he has prominently disagreed with the political goals of some religious groups, including the Catholic Church, he also has often proved that he understands them.

“When you went to an event in Washington, D.C., with [Biden], it was the only room that included priests and nuns," said Christopher Jolly Hale, who was executive director of Catholics in Alliance for the Common Good during the Obama administration and is now running for Congress in Tennessee. “It was always strange to see the habits and collars among the most powerful in Washington.”

Others noted that Biden almost always has rosary beads in his pocket, and frequently holds them in his hand — including while he monitored the raid that killed Osama Bin Laden in 2011. He has written and spoken at length of how faith helped him grieve the loss of his first wife and daughter many years ago, and his son Beau more recently.

Biden declined an interview request. In a statement, he called Trump’s attack “shameful,” saying that his faith is the “bedrock foundation of my life."

”President Trump’s decision today to profane God and to smear my faith in a political attack," Biden said, "is a stark reminder of what the stakes of this fight truly are.”

Like John F. Kennedy, the only Catholic president to date, Biden has been criticized from both the right and the left for policy stances that are related to his religion, especially on the issue of abortion.

For years, certain U.S. bishops — including, in 2008, the bishop of Scranton, Pa., Biden’s birthplace — have said that Biden should not be allowed to take communion in Catholic churches because of his support for legal access to abortion. Catholic schools have banned him from speaking because of the issue.

And some Democrats have said his advocacy for legal abortion did not go far enough, especially for the many years he supported the Hyde Amendment, which bans federal funding for abortion.

When Biden helped lead the charge to pass President Barack Obama’s Affordable Care Act, the U.S. Conference of Catholic Bishops criticized the law’s requirement that employers provide insurance coverage to their workers for contraception, which the Catholic Church opposes.

Sister Carol Keehan, a key supporter of the health-care law who was the president of the Catholic Health Association at the time, said Biden tried to be a liaison between Catholic leaders and the White House to get the law passed. He called several bishops to discuss how the law would affect funding for abortion.

Sister Simone Campbell, another leading activist-nun who advocated for the law, said Biden — more than others in the White House — understood the bishops’ concerns about the law and worked hard to solve them. “I wouldn’t go as far as ‘sympathetic,’ ” to the bishops’ perspective, she said, describing Biden’s attitude. “I think it was more pragmatic.”

But, she added, the vice president’s knowledge of the Catholic point of view was useful.

On the day the law was signed, Campbell said, she introduced herself to Biden at a victory party. "He proceeded to have this very heartfelt celebration about how much the Affordable Care Act passage was for him about faith,” she said. “He didn’t say ‘Jesus.’ He doesn’t talk about that. He talks about the mandate to care for the most vulnerable.”

Biden said recently that if elected, he would restore the policy that existed before the Hobby Lobby ruling: providing an exemption to the contraceptive mandate for houses of worship and an accommodation for nonprofit organizations with religious missions.

Michael Wear, who was a faith outreach leader for Obama, said if Biden becomes president, “there will be real differences of opinion" between his policy platform and that of the Catholic Church. But those differences, he said, "won’t come from a place of antagonism, and they won’t come from a place of not understanding.”

Catholics, who make up nearly one-quarter of voters, historically are politically split, with Latino Catholics favoring Democrats and White Catholics somewhat more favorable toward Republicans. Polling by Pew Research Center in July showed Biden slightly leading Trump among Catholic voters, 52 percent to 47 percent.

Trump is far less popular with White Catholics than with White evangelical Protestants, who also strongly oppose abortion.

The Rev. Frank Pavone, a Trump supporter who leads the conservative group Priests for Life, said that many Catholic Americans might agree with Trump that Biden is “anti-God.”

“He says he’s a devout Catholic and yet embraces policies that are contrary to the Catholic faith,” said Pavone, who wrote a letter to Biden saying he could not be Catholic while defending abortion rights. “It’s not like Biden is saying, ‘Let’s outlaw belief in God.’ But what Trump is saying is not an exaggeration.”

Rocco Palmo, editor of Whispers in Loggia, a news site on Catholicism, questioned Trump’s connection of support for gun ownership to religious belief, noting that Catholic bishops have spoken out several times on the need for gun restrictions.

"Some Catholics are going to say, ‘You don’t tell us who’s one of us and who isn’t,’ " Palmo said. “Since when was that the role of government? The bishops are the authoritative teachers of the faith, not the president of the United States.”

Biden’s view of faith in policy-making extends to many issues beyond abortion. Campbell was struck that when Obama put Biden in charge of a gun control task force in 2013, Biden convened a meeting of faith leaders — not an obvious constituency — to give him ideas. He also worked as vice president with the clergy group Circle of Protection to oppose budget cuts being pushed by then-House Speaker Paul D. Ryan (R-Wis.).

Joshua DuBois, who led Obama’s Office of Faith-Based and Neighborhood Partnerships, said that in the right circumstances, Biden — who grew up in an Irish Catholic family and attended Catholic schools — opens up easily about his faith. When DuBois prepared him for a series of radio interviews one Father’s Day, “I couldn’t get in the door without him talking about how the love that God gives him as his heavenly father," Dubois said. "He feels like his most important part of his faith is to give that love to his kids.”

Biden has not commented publicly on Pope Francis’s struggle to address claims of widespread sexual abuse by priests, and efforts to cover up those allegations by individual dioceses and the Vatican. But Keehan says that in private, he has expressed his frustration. "He has been stressed and profoundly disappointed in the sex abuse crisis,” she said. “I can tell you that it’s been very challenging for him.”

The relationship between the U.S. government and the Vatican has been uneasy since Trump’s election in 2016. Francis has provoked Trump several times, including calling him “not Christian.” Trump, in response, called the pope’s words “disgraceful.”

Biden’s campaign, and Catholic Democrats who have worked with him, say that Biden would repair the bond — a relationship with diplomatic implications, not just religious ones, as the Vatican has a history of working with Washington to deliver aid in global trouble spots and of brokering international agreements.

In a call earlier this year with Catholic leaders, Trump called himself the “best [president] in the history of the Catholic Church,” according to the online Catholic newspaper Crux. He has campaigned hard to win Catholic votes, particularly White Catholics in key swing states like Pennsylvania and Wisconsin.

Biden, too, is reaching out to Catholics, holding prayer calls and Zoom meetings for faith leaders and planning virtual house parties where supporters can invite friends from their parishes to talk about electing the next Catholic president.

Campbell, the nun who advocated for Obamacare, remembers her family’s joy when Kennedy was elected in 1960, even though some of his policy positions clashed with the church.

If Biden became the second Catholic in the Oval Office, Campbell said, “There would be pride in that."