Capocci was born at Viterbo in 1180–1190. Few details exist about his early life, and his alleged adherence to the Cistercian Order, including the role of abbot the Tre Fontane Abbey in Rome, is unconfirmed. He entered the Roman curia before 1215, the year in which Pope Innocent III sent him to the Abbey of Montecassino to investigate about abbot Adenulf's tenure. In 1216 Capocci was created cardinal deacon of Santa Maria in Cosmedin, and later became papal legate to Lombardy.
In 1234 the new pope Gregory IX named Capocci rector of Tuscia (Tuscany), as well as capitano (commander) of the Papal troops. In the same year Luca Savelli, grandson of Honorius III, forced the pope to flee from Rome to Umbria. Emperor (and King of Naples and Sicily) Frederick II moved from southern Italy with an army to help Gregory, joining Capocci's troops at Montefiascone. Savelli's army was besieged in fortress a few kilometers south to Viterbo and, although Frederick left the siege in advance, Capocci was able to defeat them. Frederick's ambiguous behaviour led to his excommunication by Gregory four years later, and Capocci defended the pope's move with a series of letter and treatise spread to Europe, including the manifesto Ascendit de mare.
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 show any compromise to 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 power (he was also bishop of Viterbo for one year).
In 1244 a peace was signed between Innocent and Frederick. However, the latter soon became military and diplomatic moves to overthrow the pope, who decided to take refuge in Lyon, leaving Capocci as his plenipotentiary in Italy. When he news arrived that a compromise with the emperor was likely, he had a series of pamphlet, full of insults and accuses of heresy against Frederick, published in the French city: their success among the prelates in the First Council of Lyon led to the deposition of the Sicilian leader (1245). Frederick replied by reconquering Viterbo, although Capocci was able to gain back most of Umbria and the March of Ancona, including Iesi, the emperor's birthplace. In 1246 Innocent appointed him as papal legate also in the Kingdom of Sicily.
In October 1249, however, Innocent started to consider Capocci's power as excessive, and called him back to the Roman curia. Ranieri never accepted the decision and, now ill, moved to Lyon, where he died in 1250. He was initially buried in the Abbey of Citeaux, but later his remains were transferred in the church of Santa Maria in Gradi at Viterbo, which he had built in 1217–1221 as a gift to his personal friend, Saint Dominic.
- Gregorovius, Ferdinand (1973). Storia della Città di Roma nel medioevo. Turin: Einaudi.
- Signorelli, Giuseppe (1907). Viterbo nella Storia della Chiesa. Viterbo: Cionfi.