RIO DE JANEIRO -- The “slum pope” returned to the slum.

Pope Francis on Thursday visited one of Rio de Janeiro’s shantytowns, or favelas, a place that saw such rough violence in the past that it’s known by locals as the Gaza Strip.

Despite heavy security and a cold rain, Francis waded into the crowds without an umbrella and hugged and kissed residents young and old before heading into the shoebox of a church that serves the Varghina community. There he blessed a new altar.

His open-air car was mobbed on a few occasions as he headed into the community of flimsy, brick shacks, but he never seemed in danger. In fact he was showered with gifts as he walked down one of the main drags of the neighborhood: a paper lei, or necklace, hung around his neck and he held up a scarf from his favorite soccer team, Buenos Aires’ San Lorenzo that was offered to him.

He came to bring a message of hope, following in the footsteps of Pope John Paul II who visited two such favelas during a 1980 trip to Brazil and Mother Teresa who visited Varginha itself in 1972.

Like Mother Teresa, Francis brings his own personal history to the visit: As archbishop of Buenos Aires, then-Cardinal Jorge Mario Bergoglio frequently preached in the poverty-wracked slums of his native city, putting into action his belief that the Catholic Church must go to the farthest peripheries to preach and not sit back and wait for the most marginalized to come to Sunday Mass.

It was one of the highlights of Francis’ weeklong trip to Brazil, his first as pope and one seemingly tailor-made for the first pope from the Americas. Later Thursday, he was to preside over a welcoming ceremony for World Youth Day, his first official event with the hundreds of thousands of young people who have flocked to a rain-soaked Rio for the church’s Catholic youth festival.

The Varginha slum butts up against what until about six months back was the largest “cracolandia” — crackland — in Brazil, where hundreds of crack cocaine users would gather under a train overpass and use the drug openly night and day. Crumbling brittle shacks give the area a bombed-out feel.

The slum on Thursday was buzzing with excitement: a group of 200 schoolchildren held blue and white balloons and construction-paper flags of yellow and green, the colors of Brazil’s flag. Every time a police helicopter buzzed overhead, the kids screamed with delight, their shrill high voices drowning out all over noises around.

“Events like this, with the pope and all the local media, get everyone so excited,” said Antonieta de Souza Costa, a 56-year-old vendor and resident of Varginha. “I think this visit is going to bring people back to the Catholic church.”

In the last two decades, the Catholic Church has lost legions of faithful — most of them poorer Brazilians who have switched to Pentecostal evangelical churches that have a huge presence in Varginha and most slums like it.

Security was tight: In addition to the police helicopters, sharpshooters perched atop nearby buildings, metal barricades held the ecstatic crowd at bay on the street and a police officer was posted every 5 feet (2 meters) apart in the slum.

Varginha is one of the smallest of Rio’s more than 1,000 slums. It’s a triangle-shaped chunk of flat, dusty land sitting between two putrid waterways full of raw sewage. On the third side runs a busy main road with an elevated commuter train that noisily rolls by overhead.

The slum’s surroundings somewhat ease security concerns, with the waterways acting as natural boundaries and only two roads 300 yards (meters) apart from one another allowing access.

Varginha is a so-called “pacified” slum — police invaded it in January and pushed out a heavily armed drug gang known as the Red Command, then set up a permanent police post in the slum that had seen virtually no government presence for decades.

The pacification program started in 2008 as an effort to secure Rio de Janeiro before it hosts the 2014 World Cup soccer tournament and the 2016 Olympics.

There are now 33 permanent police posts set up in Rio, covering 1.5 million people.

Francis started his day by receiving the keys to Rio and blessing the Olympic flag, joining a long list of popes who have shown an interest in the positive role sport can play in society.

Francis also greeted some of Brazil’s Olympic athletes during a brief visit to Rio’s City Palace on Thursday. From the balcony, he blessed the Olympic flag with holy water and imparted a blessing on those gathered. Rio de Janeiro is hosting the 2016 Summer Games.

On the eve of the London Olympics, then-Pope Benedict XVI issued a message saying he hoped the 2012 Games would help promote peace and friendship. Pope John XXIII greeted Olympians in Rome for the 1960 Games.