Cesena was on the border that the Exarchate of Ravenna shared with the Lombards. It was presented to the Papacy by its Frankish conqueror in 754 and passed back and forth between the popes and the archbishops of Ravenna, was briefly a communal republic 1183 - 1198 and was long contested between popes and Holy Roman Emperors a fief held sometimes by the Malatesta, sometimes directly held by the papacy, not without resistance.
The brief rule by the Forlivese Ordelaffi was crushed in 1357 by the Papal troops led by Cardinal Gil de Albornoz: the heroic defense of the town by Cia degli Ordelaffi, wife of the Lord of Forlì, against besieging Papal troops was ultimately unsuccessful.
The little comune revolted again in 1377 during the War of the Eight Saints. This time it was recaptured by Breton troops of Giovanni Acuto (the English-born condottiere John Hawkwood) under the command of Robert, Cardinal of Geneva, (later antipope Clement VII): the latter, acting as the legate of Pope Gregory XI, directed the savage murder of between 2,500 and 5,000 civilians, an atrocity by the rules of war at the time that earned the label the "Cesena Bloodbath" and the cardinal the "butcher of Cesena". The following year what remained of Cesena was assigned by the new pope Urban VI to Galeotto I Malatesta.
During the period 1379-1465 the city recovered and prospered under the Malatesta, who rebuilt the castle (called Rocca Malatestiana) overlooking the town. The Malatestiana Library, built by near the castle by Malatesta Novello (1429), is considered a fine example of a Renaissance library and holds many valuable manuscripts.
After Novello's death (1465), Cesena returned to direct Papal control, but was again seized by a local seignor, Cesare Borgia, in 1500. The city was elevated to capital of his powerful though short-lived duchy.
Cesena subsequently turned into a secondary city of the Papal States. In the 18th and 19th centuries Cesena gave births to two popes, Pope Pius VI and Pope Pius VII, and once had Pope Pius VIII as bishop, gaining the "city of the three popes" title. During the Napoleonic Wars it was stripped of numerous monasteries and churches. Some of its citizens had notable roles in the unification of Italy, in second half of the 19th century.
In 1992 it was elevated to the rank of co-capital of province, together with Forlì.