VATICAN CITY β€” Pope Francis thanked aid groups that rescue migrants at sea on Friday and denounced the "sterile hypocrisy" of governments that turn a blind eye to people seeking security and dignified lives.

In a direct critique of policies in parts of Europe and the United States, Francis celebrated a special Mass for migrants and the activists who care for them. The intimate service in St. Peter's Basilica was held as Italy, the U.S. and other countries increasingly close their doors, ports and borders to asylum-seekers.

"Before the challenges of contemporary movements of migration, the only reasonable response is one of solidarity and mercy," the pope said.

The Mass marked the fifth anniversary of Francis' landmark visit to Lampedusa, the Sicilian island that for years was the primary destination of migrants smuggled from Libya to Europe. During the trip, Francis' first outside Rome after his 2013 election, the new pope denounced the "globalization of indifference" that the world showed migrants fleeing war, poverty and climate-induced natural disasters.

In the years since, and especially in recent months, some governments have adopted tough anti-migrant policies that fly in the face of Francis' oft-repeated call for governments to open their hearts and doors to those in need.

Italy and Malta, in particular, have closed their ports to aid groups operating migrant rescue boats in the Mediterranean Sea, while the Trump administration imposed a now-abandoned policy to separate children from their parents at the U.S.-Mexico border.

Francis didn't name any countries in his homily, but he said every country must consider if the responsibility for welcoming migrants is being shared equitably.

Referring to the biblical story of the Good Samaritan, Francis denounced the "sterile hypocrisy of those who do not want to dirty their hands" by caring for the weakest and most marginalized members of society.

"It takes the form of closing our hearts to those who have the right, just as we do, to security and dignified living conditions. It builds walls, real or virtual, rather than bridges," he said.

Speaking in his native Spanish, Francis thanked the representatives of aid groups who were attending the Mass for embodying the Good Samaritan "who stopped to save the life of the poor man beaten by bandits."

"He didn't ask where he was from, his reasons for travelling or his documents. he simply decided to care for him and save his life," Francis said.

The mention was notable given Italy's new anti-migrant interior minister, Matteo Salvini, has accused aid groups of essentially working as "taxi services" for Libyan-based smugglers and denied them entry to Italian ports.

Italian and Maltese prosecutors have opened investigations against some humanitarian groups, accusing them of complicity with traffickers. The groups deny the allegations.

Among those invited to the Mass was Oscar Camps, founder of Spanish aid group Proactiva Open Arms. The group's ship brought 60 migrants to Spain this week after Italy and Malta refused the vessel entry.

Camps was angry about being turned away by the two countries when the Open Arms reached Barcelona on Wednesday. Hundreds of other migrants drowned during the ship's four-day journey to Spain.

He thanked Francis for his support, calling them "a very important recognition of the work we are doing."

"The pope has always defended the fact that human life at sea must be protected," Camps said.