Krakow - Pope Francis encouraged hundreds of thousands of young people at a global gathering of the faithful Sunday to "believe in a new humanity" that is stronger than evil and refuses to see borders as barriers.His appeal came at the end of World Youth Day, a week long event being held in southern Poland this year that draws young Catholics from around the world every two to three years for a spiritual pep rally.The youth gathering was Francis' main focus during his pilgrimage to Poland, but over five days in this deeply Catholic nation he also prayed at the former Nazi Auschwitz death camp and implored God to keep away a devastating wave of terrorism now hitting the world. He also met with Poland's political and church leaders.For a second straight day, a huge crowd filled a vast field on Sunday in the gentle countryside outside the city of Krakow to see Francis, who was visiting central and eastern Europe for the first time. Security was very high throughout the pope's visit, coming at a time of terror attacks in Western Europe.Many of the faithful had camped out overnight after an evening of entertainment and prayer with the pope in the same field on Saturday night that drew 1.6 million people, according World Youth Day organisers.Sunday's faithful numbered at least in the hundreds of thousands. The Reverend Federico Lombardi, a Vatican spokesperson, referred to an estimate by Polish authorities of 1.5 million at Sunday's closing mass.The pope used his several encounters with the young pilgrims - from mega-gatherings to a private lunch with only a dozen people from five continents - to encourage a new generation to work for peace, reconciliation and justice.God, said Francis in his final homily of the pilgrimage, "demands of us real courage, the courage to be more powerful than evil, by loving everyone, even our enemies"."People may judge you to be dreamers, because you believe in a new humanity, one that rejects hatred between peoples, one that refuses to see borders as barriers and can cherish its own traditions without being self-centred or small-minded," Francis told his flock, many of them in their late teens, 20s or 30s.High securityEarlier in his pilgrimage, Francis had expressed dismay that many people and places aren't welcoming enough to refugees or those fleeing poverty in their homelands.After over 1 million people arrived on Europe's southern shores last year, some nations on the continent, notably in central and eastern Europe, hastily built fences to keep the refugees out. Poland has been among the EU countries that have refused to take in many Muslim refugees, saying it has already welcomed hundreds of thousands of Ukrainian immigrants.Attending Francis' closing mass on Sunday were some of Poland's top leaders, including President Andrzej Duda and Jaroslaw Kaczynski, head of the conservative ruling Law and Justice party.Another message that Francis countered head-on was the world of computer screens and video games, which he says are contributing to a "paralysis" among young people. He exhorted them on Saturday evening not to be "couch potatoes" seeking merely an easy life, but to instead take risks and make their mark so the world is more kind and just.The World Youth Day events took place amid very high security following a string of extremist attacks in Western Europe, with an elderly French priest being slain in his Normandy church on Tuesday, the day before Francis arrived in Poland.Since the Paris extremist attacks in early 2015, concerns have heightened that the Vatican, and the pope in particular, could be targeted because of his role as the most influential Christian leader. When the pope travels, a corps of Vatican bodyguards travels with him, running alongside his popemobile or scrutinising crowds along the route.On Saturday, at a mass attended mainly by Polish priests, nuns and seminarians, sniffer dogs patrolled the perimeter, searching for explosives. Police opened every bag of those entering and waved metal-detecting wands carefully over each person.At Sunday's mass, several Polish police vans followed the pope's open-sided popemobile as he rode through the wide flat meadow in the middle of the hundreds of thousands of pilgrims. Motorcycle police rode close to metal barriers keeping the crowd away.Francis also spoke of terrorism in some of his public remarks and made an unscheduled stop on Saturday at a Franciscan church in Krakow, where he implored God in prayer to "keep away the devastating wave of terrorism" in much of the world and to "touch the hearts of the terrorists, so that they recognize the evil of their actions and return to the path of peace and of good".At the end of Sunday's mass, Francis announced that the next World Youth Day will take place in Panama in 2019.