In 1177, in a period when the castle was the bone of contention between the Emperor and the Pope, the emperor Frederick Barbarossa stayed there for some months. The fortress later became first the residence of the papal governors of Romagna in the 13th and 14th centuries and then the residence of the Malatesta family until 1465