Pope Francis thanked aid groups that rescue and care for migrants on Friday and denounced the "sterile hypocrisy" of those who turn a blind eye to the world's poor seeking security and a dignified life.

Francis celebrated a special Mass for migrants and those who care for them in St. Peter's Basilica, calling attention to their plight as Europe, the U.S. and other countries increasingly close their doors, ports and borders to them.

The intimate service 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 that 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, governments in Italy, the U.S., Hungary and elsewhere 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 that rescue migrants in the Mediterranean, while the Trump administration imposed a now-abandoned policy to separate children from their parents at the U.S.-Mexico border.

Francis didn't refer to any country by name in his homily, but he said the only "reasonable response" to the global migration phenomenon today is to show solidarity and mercy. The response, he said, must take into account equitable distribution of responsibilities while ensuring the rights and dignity of all.

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 marginal of society.

Such a temptation, he said, is "powerfully present" today as the world grapples with migration flows.

"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 in the pews 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 has closed Italy's ports to their rescue ships.