As Cardinal Bishop of Ostia he had been in the inner circle of Honorius, and associated with the pope's policy of accommodation with the formidable Hohenstaufen emperor Frederick II, whose lawyers in Naples and Capua asserted his position as universal temporal ruler, in the mold of Constantine.
Gregory began his pontificate by suspending the emperor, then lying sick at Otranto, for dilatoriness in carrying out the promised Sixth Crusade. The suspension was followed by excommunication and threats of deposition, as deeper rifts appeared— Frederick's control of the Sicilian Church, his feudal obligations to the pope, even his continued presence in Sicily. Frederick publicly appealed to the sovereigns of Europe complaining of his treatment. Frederick went to the Holy Land and skirmished with the Saracens to fulfill his vow, but was soon back in Italy, where Gregory had taken advantage of his absence by invading his territories. A consequent invasion of the Papal states in 1228 having proved unsuccessful, the emperor was constrained to give in his submission and beg for absolution.
Although peace was thus secured (August 1230) for a season, the Roman people were far from satisfied; driven by a revolt from his own capital in June 1232, the pope was compelled to take refuge at Anagni and invoke the aid of Frederick. Pope and Hohenstaufen came to a truce, but when Frederick defeated the Lombard League in 1239, the possibility that he might dominate all of Italy, surrounding the Papal States, became a very real threat. A new outbreak of hostility led to a fresh excommunication of the emperor in 1239, and to a prolonged war.
Gregory denounced Frederick as a heretic and summoned a council at Rome to give point to his anathema, at which Frederick attempted to capture or sink as many ships carrying prelates to the synod as he could. The struggle was only terminated by the death of Gregory on August 22, 1241. Gregory died before events could reach their climax; it was his successor, aptly named Innocent IV who declared a crusade in 1245 that would finish the Hohenstaufen threat.
This pope being a remarkably skilful and learned lawyer, caused to be prepared Nova Compilatio decretalium, which was promulgated in numerous copies in 1234. (It was first printed at Mainz in 1473). This New Compilation of Decretals was the culmination of a long process of systematising the mass of pronouncements that had accumulated since the Early Middle Ages, a process that had been under way since the first half of the 12th century and had come to fruition in the Decretum compiled and edited by the papally-commissioned legist Gratian and published in 1140. The supplement completed the work, which provided the foundation for papal legal theory.
He canonized Saints Elizabeth, Dominic and Anthony of Padua, and also Francis of Assisi, of whom he had been a personal friend and early patron. His encroachments upon the rights of the English Church during the reign of Henry III are well known; similar attempts against the liberties of the national church of France were supposedly the occasion of the Pragmatic Sanction of St. Louis, now generally thought to be a 14th-century forgery.
Gregory transformed a chapel to Our Lady in the church of Santa Maria del Popolo in Rome.