Pope Francis celebrated an open-air Mass before a huge crowd on Sunday at a riverside park near Lisbon to wrap up an international jamboree of Catholic youth.
Around 1.5 million people attended the service at the Parque Tejo park on the outskirts of the Portuguese capital, the Vatican said.
The crowd waved national flags and cheered as the 86-year-old pope arrived at the park, which was built for the occasion on a former landfill site.
Many had camped out overnight in sleeping bags or floor mats.
With little shade in the park, pilgrims protected themselves from the sun with umbrellas or makeshift tents made from sheets.
"It's extraordinary to be able to be here to see our Pope Francis who has managed to gather people from the whole world," Pimentel Gomes, a 52-year-old priest from Brazil, told AFP as he sat for breakfast before the Mass.
The weather is a concern with temperatures expected to soar to 41 degrees Celsius (106 degrees Fahrenheit).
Portugal's state weather agency has issued a "red" alert -- its highest level -- for Lisbon on Sunday due to the heat.
At a vigil in the park on Saturday night the pope urged pilgrims to "pick themselves up" whenever they suffer a setback in life.
"Those who remain on the ground have retired from life, have lost their hopes and dreams," he added.
Drones formed the words "rise up" and "follow me" in the sky above the stage as the pope spoke.
The Argentine pope is in increasingly fragile health, and now uses a wheelchair or walking stick to get around.
This is his first foreign trip since he spent nine nights in hospital after undergoing hernia surgery in June.
Charlotte Bordas, a 26-year-old who came from Mont-de-Marsan in southwestern France, said she was moved to see the pope had made the trip despite his health problems.
"We see he's really tired, weakened, but he still took the time to come to see us, talk to us, and it particularly touches me to see him," she told AFP.
- 'Important messages' -
Francis arrived in Portugal on Wednesday for World Youth Day, a six-day international Catholic jamboree featuring festive, cultural and religious events.
It comes as Francis attempts to galvanise young Catholics at a time when secularism and priest paedophilia scandals cause some to abandon pews in Europe.
The pope met 13 victims of clerical abuse at the Holy See's diplomatic mission in Lisbon during his first day in Portugal.
"The meeting was held in an atmosphere of intense listening and lasted more than an hour," the Vatican said.
He also met 15 youths from war-torn Ukraine's delegation, visited a community centre in Lisbon's impoverished Serafina neighbourhood and prayed at the shrine of Fatima north of the Portuguese capital.
"It has been an extraordinary moment of joy, of energy, with remarkable speeches by the Holy Father, with very important messages for society and political leaders," Portuguese Prime Minister Antonio Costa told public television RTP.
Francis has received an enthusiastic welcome throughout his visit to the Catholic-majority country, with well-wishers lining the streets to see him go by.
World Youth Day, created in 1986 by John Paul II, is the largest Catholic gathering in the world and features a wide range of events, including concerts and prayer sessions.
This edition, initially scheduled for August 2022 but postponed because of the pandemic, will be the fourth for Francis after Rio de Janeiro in 2013, Krakow in 2016 and Panama in 2019.
bur-ds/imm