During a visit to the Varginha favela, or slum, the pope told poor people: "You are not alone. The church is with you, the pope is with you."
Brazilian police took over Varginha last year, taking control from drug gangs, CNN said.
The pope, visiting Brazil after weeks of sometime violent anti-corruption protests, told young Brazilians: "You have a particular sensitivity towards injustice, but you are often disappointed by facts that speak of corruption on the part of people who put their own interests before the common good.
"To you and to all, I repeat: never yield to discouragement, do not lose trust, do not allow your hope to be extinguished," he said.
"The measure of the greatness of a society is found in the way it treats those most in need, those who have nothing apart from their poverty!"
Speaking to a crowd of about 3,000 at a soccer stadium, Francis said he would like to visit every home in Brazil.
The pope was to lead a religious celebration Thursday on Copacabana Beach, with about 1 million people expected to attend, CNN said.
The pope Wednesday blessed a new wing of the St. Francis of Assisi hospital in Brazil dedicated to the rehabilitation of drug users, saying he embraces people who are struggling with addiction. The pope said it is necessary to confront the problems underlying drug use, adding the decriminalization of drug use -- as is being proposed in some Latin American areas -- will not help.
As he celebrated the first public mass of his Brazil visit Wednesday, at one of Latin America's largest shrines, the pope urged Catholics to shun the idols of material success, power and pleasure during the mass, and said he plans to return in 2017, The New York Times said.
The pope's first international visit has been complicated by organizational problems, the newspaper said.
When he arrived, his motorcade got stuck in traffic and he was exposed to a mob of people trying to touch him through an open window.
Volunteers helped hold back crowds as police and military personnel lined the pope's motorcade route, CNN reported.