Pope Francis has called for young people in Brazil to build a more united world, in his first Mass outside Italy since he was elected pope earlier this year.
The pope celebrated Mass in southeastern Brazil with tens of thousands of Roman Catholics at the shrine of the Virgin of Aparecida, the country's symbol of the Virgin Mary.
He says, "I too come to knock on the door of the house of Mary - who loved and raised Jesus - that she may help all of us, pastors of God's people, parents and educators, to pass on to our young people the values that can help them build a nation and a world which are more just, united and fraternal.''
Officials estimated about 150,000 gathered at the shrine during Francis' visit. He pledged to the people he would return to the country in 2017.
After visiting the shrine, Pope Francis is returning to Rio de Janeiro to meet with young prison inmates and visit shantytowns largely cleared of drug gangs earlier this year. He will also inaugurate a Rio hospital wing for the treatment of drug addicts.
On Thursday, more than a million young Catholics are expected to descend on Rio to take part in the international celebration of World Youth Day.
The 76-year-old Pope Francis was greeted like a rock star upon his arrival Monday in Rio de Janeiro, cheered by thousands of people who lined the streets to view his passing motorcade. But the trip was marred by a major security lapse after his car took a wrong turn onto a busy street and was mobbed by well wishers.
Throughout the ordeal, the pope himself appeared upbeat and kept his car window open to greet the crowds that swarmed his motorcade.
The visit to Brazil, and his return to his home continent of South America, is the former Argentine-born Cardinal Jorge Bergoglio's first foreign trip since he was elected pope in March.