Pope Francis has closed World Youth Day festival in Rio de Janeiro with a Mass on Copacabana beach.
More than three million people are estimated to have gathered for the service in the city of Rio de Janeiro.
Many of the pilgrims had slept on the beach after attending an all-night vigil, which Pope Francis also led.
Sunday’s ceremony marks the end of the Pope’s five-day visit to Brazil – his first foreign trip since becoming pontiff in March.
Pope Francis is set to fly back to Rome later on Sunday.
Correspondents say almost every inch of the two-and-a-half mile long beach was occupied ahead of the Mass, as most of the young people stayed after the vigil, pitching tents or sleeping in the open.
The vigil and Sunday mass have attracted the biggest crowd ever to Copacabana beach, which has hosted rock concerts, sports events and the traditional New Year celebrations.
Pope Francis encouraged young Catholics to get out of their parochial boundaries in order to help others.
“Go and don’t be afraid of serving,” he said.
“Jesus did not gather the Apostles so they lived in isolation. He called them so they formed a group, a community,” said Pope Francis.
Pope Francis announced the next Catholic youth festival would be held in the Polish city of Krakow in 2016.
Female activists held a demonstration nearby in support of abortion and women’s rights.
In the past three decades, the Catholic church has lost millions of followers to smaller Christian denominations.
In his vigil address on Saturday, the pontiff had urged the pilgrims not to be “part-time Christians”, but to lead full, meaningful lives.
Speaking on a huge stage at the beach where a mock church structure was built, Pope Francis referred to the street protests which have been taking place in Brazil for more than a month.
“The young people in the street are the ones who want to be actors of change. Please don’t let others be actors of change,” he told the crowd at the vigil.
“Keep overcoming apathy and offering a Christian response to the social and political concerns taking place in different parts of the world.”
Also on Saturday, the Pope repeated his challenge to fellow Roman Catholic clerics to take to the streets.