Pope Francis flew back to Rio de Janeiro after celebrating his first public Mass in a cavernous rural Brazilian basilica Wednesday.

During Mass in Aparecida, a small town halfway between Rio and Sao Paulo, Francis urged Catholics to resist the “ephemeral idols” of money, power and pleasure.

It was the first public Mass celebrated by Francis during his initial international foreign journey as pontiff, and it was an emotional trip to one of the most important shrines in Latin America.

Thousands packed into the huge Basilica of the Shrine of Our Lady of Aparecida, tucked into an agricultural region of verdant fields, and tens of thousands more braved a cold rain outside to catch a glimpse of the first pope from the Americas returning to a shrine of great meaning to the continent and to him personally.

Before the Mass, Francis stood in silent prayer in front of the 15-inch-tall image of the Virgin of Aparecida, the “Black Mary,” his eyes tearing up as he breathed heavily. It was a deeply personal moment for this pontiff, who has entrusted his papacy to the Virgin Mary and, like many Catholics in Latin America, places great importance in devotion to Mary.

After his Mass, the pope blessed the tens of thousands gathered outside the basilica and announced that he would return to Aparecida in 2017, the year that marks the 300th anniversary of a fisherman finding the Black Mary statue in a nearby river.

During his homily, Francis urged Catholics to keep their values of faith, generosity and fraternity, a message he was expected to repeat later in the day during a visit to a drug rehabilitation center in Rio de Janeiro.

“It is true that nowadays, to some extent, everyone including our young people feels attracted by the many idols which take the place of God and appear to offer hope: money, success, power, pleasure,” he said. “Often a growing sense of loneliness and emptiness in the hearts of many people leads them to seek satisfaction in these ephemeral idols.”

The church is struggling in Latin America to keep Catholics from straying to evangelical and Pentecostal churches that often promise help in finding material wealth, an alluring attraction in a poverty-wracked continent. Francis’ top priority as pope has been to reach out to the world’s poor and inspire Catholic leaders to go to slums and other peripheries to preach.

Unlike the scenes of chaos that greeted Francis on his Monday arrival in Rio, when a mob of faithful swarmed his motorcade from the airport, the security situation in Aparecida was far more controlled. Chest-high barriers kept the faithful far from his car. Soldiers in camouflage, emergency crews in raincoats and other uniformed security forces stood guard along his route while his bodyguards walked along the side of his open-air vehicle.

However, while riding back to catch a flight back to Rio de Janeiro, Francis halted the motorcade and descended to his right. He went over to the barricade, greeted a crowd and kissed a baby handed his way. Francis then went to the other side of the road and kissed another toddler held aloft by a crowd of people.

The pontiff has kissed several babies each time he’s encountered the public in Brazil.