The event was also attended by 3,000 others including prison staff and volunteers and without any visible police presence.
The Argentine pontiff regularly meets prisoners -- both in Italy and on his trips abroad -- but this is the first time so many inmates were received at the Vatican.
The pontiff, recalling his visits to jail, said: "Every time I enter a prison, I ask the question 'why them and not me?', we all can make mistakes."
He exhorted them never to lose hope.
More From This Section
"Hope is a gift of God," he said. "Certainly, breaking the law involves paying the price, and losing one's freedom is the worst part of serving time, because it affects us so deeply. All the same, hope must not falter."
He said that incarceration was not the only means to set people back on the right path.
"Sometimes, a certain hypocrisy leads to people considering you only as wrongdoers, for whom prison is the sole answer," he said.