Pope Francis celebrated mass Sunday with over 1.5 million pilgrims in a vast sun-drenched field in Poland, wrapping up an emotionally charged trip with some choice technological metaphors.
In a nod to today's internet-dominated world, Francis urged the faithful, who had travelled to Poland from all over the world, to "download the best link of all, that of a heart which sees and transmits goodness without growing weary".
"Make the Gospel your own, so that it can serve as a satnav for you on the highways of life," he said during the service.
High-spirited teenagers, boy scouts, priests and families had camped under the stars in the vast "Campus Misericordiae" (Field of Mercy) near the city of Krakow ahead of the final mass of a week-long Catholic festival.
Francis encouraged the assembled worshippers to be dreamers who believe "in a new humanity", one that "rejects hatred between peoples" and "refuses to see borders and barriers".
- Wave of terrorism -
In the plane on his return trip to Rome, the pontiff said Islam could not be equated with terrorism, saying Catholics could be just as deadly and warning social injustices in Europe were pushing its young into the arms of extremists.
"It's not true and it's not correct (to say) Islam is terrorism," he said, defending his decision not to name Islam when condemning the brutal murder of a Catholic priest in France in the latest of a string of recent attacks in Europe claimed by the Islamic State (IS) group.
"In almost every religion there is always a small group of fundamentalists. We have them too," he said.
He said Europe should look closer to home, saying "terrorism... grows where the God of money is put first" and "where there are no other options".
"How many of our European young have we left empty of ideals, with no work, so they turn to drugs, to alcohol, and sign up with fundamentalist groups?" he asked.
The trip's final festivities were attended by "between 2.5 and 3.0 million people," 2016 World Youth Day spokeswoman Anna Chmura told AFP. Polish police put the number at "over 1.5 million".
Hundreds of thousands of people had streamed to the grassy site on Saturday with folding chairs, sleeping bags, umbrellas and sun-hats.
"This is the trip of a lifetime, for me and my whole family," said 29-year-old Mexican pilgrim Isaac Victoria, as volunteers handed out bottles of water to the thirsty crowd.
At the evening vigil on Saturday, Francis warned that today's technology had its dangers, chastising "drowsy and dull kids who confuse happiness with a sofa", and urging them to get out and live life rather than spending it glued to their smartphones.
Francis announced that the next World Youth Day would be held in Panama in 2019.
Latin America's first pontiff had faced stiff competition at the start of his five-day trip with the memory of immensely popular Polish pope John Paul II, whom Catholics recognise as a saint. But Francis quickly made the festivities his own.
After a sombre and silent visit to the Nazi death camp in Auschwitz, he warned that the cruelty seen there "did not end" with World War II.
The "world is at war", Francis said, but the way to "overcome fear" was to welcome people fleeing conflicts and persecution -- a message with particular resonance in Poland, which has taken a hard line against refugees.
On Saturday he prayed for God to rid the world of the "devastating wave of terrorism".
"In these dangerous times, he is convincing people not to be afraid to open up," pilgrim Kasia Czajka, 40, said.
"While John Paul II was especially focused on the young, Francis is for all people in need".
- 'Multiculturalism as opportunity' -
The medieval centre of Krakow has been overrun all week by flag-waving groups from China to Samoa and Mexico, who were entertained between masses with concerts, break-dancing and football matches.
But Friday was a day of mourning as Francis walked silently through the notorious wrought-iron "Arbeit Macht Frei" (Work Sets You Free) gate at the Auschwitz-Birkenau camp, where 1.1 million people were murdered.
Freeing himself from the imposing security laid on for his visit, Francis sat on a bench among the trees and bowed his head in prayer before meeting Holocaust survivors and Catholics who had helped save Jews.
"Lord, have mercy on your people. Lord, forgive so much cruelty," the pope wrote in a memorial book.
In a heartfelt appeal to the world's young, he said it was up to them to fight xenophobia and "teach us how to live in diversity, in dialogue, to experience multiculturalism not as a threat, but an opportunity".