The pontiff arrived in the poor, crime-ridden Scampia area of the city in a popemobile and immediately plunged into a crowd of children and young people, two of whom managed to pose for a selfie with the pontiff.
"Corruption stinks, corrupt society stinks," he told residents, adding that "we all have the potential to be corrupt and to slip into criminality".
"Convert to love and peace. It is always possible to return to an honest life. There are mothers weeping for it in Naples' churches," Francis told some 100,000 people gathered for Mass in Piazza del Plebiscito in Naples' historic centre.
Security was tight for the visit: apart from risks posed by gangsters with a grudge, the pope has been threatened by the Islamic State group and trips outside the Vatican are considered prime opportunities for assassination attempts.
Also Read
After a massacre at a Tunisian museum this week claimed by the IS group, all eyes were on the elderly pontiff's safety, with 3,000 extra policemen deployed along the route he will take, including snipers on the rooftops.
The pope, who frequently focuses on the plight of the downtrodden, spent about an hour and a half with some 120 inmates, including transsexuals, at the city's overcrowded Poggioreale prison, where 2,500 prisoners are squeezed into a space for 1,400.
"Even the bars of a prison cannot separate you from God's love. Even if you have erred, the lord does not grow tired of showing you the way back," Francis said.
The pope also pleaded for shelter for the African and Asian immigrants who have flooded into the Italian city and have ended up homeless.