when gregory died in 1241, capocci was jailed by the roman senator matteo rosso orsini in the septizodium. after the short reign of celestine iv (17 days), ranieri supported the election of a pope who would not show any compromise with frederick ii. the new pope was the genoese innocent iv, who would continue gregory's anti-imperial policy. this is manifest in the events leading to the siege of viterbo, in which capocci was instrumental in the expulsion of the imperial garrison from the city, and in the following defeat of the rescue army led by frederick in person. capocci was left in the city as papal legate with full powers (he was also bishop of viterbo for one year).