On 14 February 1837, Pope Gregory XVI appointed the 27-year-old Pecci as personal prelate even before he was ordained a priest on 31 December 1837 by the Vicar of Rome, Cardinal Carlo Odescalchi.
He celebrated his first Mass with his priest brother Giuseppe.
Shortly thereafter, Gregory XVI appointed Pecci as legate (provincial administrator) to Benevento, the smallest papal province, with a population of about 20,000.

The main problems facing Pecci were a decaying local economy, insecurity from widespread bandits, and pervasive Mafia or Camorra structures, which were often allied with aristocratic families.
Pecci arrested the most powerful aristocrat in Benevento and his troops captured others, who were either killed or imprisoned by him.
With public order restored, he turned to the economy and a reform of the tax system to stimulate trade with the neighboring provinces.

Pecci was first destined for Spoleto, a province of 100,000.
On 17 July 1841, he was sent to Perugia with 200,000 inhabitants.
His immediate concern was to prepare the province for a papal visitation in the same year.
Pope Gregory XVI visited hospitals and educational institutions for several days, asking for advice and listing questions.
The fight against corruption continued in Perugia, where Pecci investigated several incidents.
When it was claimed that a bakery was selling bread below the prescribed pound weight, he personally went there, had all bread weighed and confiscated it if below legal weight.
The confiscated bread was distributed to the poor.
On 14 February 1837, Pope Gregory XVI appointed the 27-year-old Pecci as personal prelate even before he was ordained a priest on 31 December 1837 by the Vicar of Rome, Cardinal Carlo Odescalchi. He celebrated his first Mass with his priest brother Giuseppe. Shortly thereafter, Gregory XVI appointed Pecci as legate (provincial administrator) to Benevento, the smallest papal province, with a population of about 20,000.
The main problems facing Pecci were a decaying local economy, insecurity from widespread bandits, and pervasive Mafia or Camorra structures, which were often allied with aristocratic families. Pecci arrested the most powerful aristocrat in Benevento and his troops captured others, who were either killed or imprisoned by him. With public order restored, he turned to the economy and a reform of the tax system to stimulate trade with the neighboring provinces.
Pecci was first destined for Spoleto, a province of 100,000. On 17 July 1841, he was sent to Perugia with 200,000 inhabitants. His immediate concern was to prepare the province for a papal visitation in the same year. Pope Gregory XVI visited hospitals and educational institutions for several days, asking for advice and listing questions. The fight against corruption continued in Perugia, where Pecci investigated several incidents. When it was claimed that a bakery was selling bread below the prescribed pound weight, he personally went there, had all bread weighed and confiscated it if below legal weight. The confiscated bread was distributed to the poor.
Pope Leo XIII