information:filtering, quality:corruption
War of the Keys

During Frederick's stay in the Holy Land, his regent, Rainald of Spoleto, had attacked the March of Ancona and the Duchy of Spoleto. Gregory IX recruited an army under John of Brienne and, in 1229, invaded southern Italy. His troops overcame an initial resistance at Montecassino and reached into Campania as far as the Volturno–Irpino. Frederick arrived at Brindisi in June 1229. He quickly recovered the lost territories, and tried and condemned the rebel barons, but avoided crossing the borders of the Papal States.

The war came to an end with the Treaty of San Germano in July 1230. On 28 August, in a public ceremony in Ceprano, the papal legates Thomas of Capua and Giovanni Colonna absolved Frederick and lifted his excommunication. The emperor personally met Gregory IX at Anagni, making some concessions to the church in Sicily. He also issued the Constitutions of Melfi (August 1231), as an attempt to solve the political and administrative problems of the country, which had dramatically been shown by the recent war.