On top of Torraccio in the Middle Age stood the Gagliole castle; allegedly built by a certain Galliolo that would build in 1035 naming it after himself. More likely the castle's name comes from the word Lombard gahagi = fence, and perhaps it was built between the seventh and eighth centuries as a defensive outpost of the Lombard Duchy of Spoleto. In 1290 it was owned by Massa nobles Raniero and Galgano Bonaccorsi and 14 families lived there.
Impregnable Guelph stronghold, it was repeatedly attacked in vain by the Ghibellines of Todi until 1307, when it was purchased by the town of Todi, destroyed and razed to the ground. Today, only a few ruins of the castle of Gagliole remain, choked by vegetation. It had in its appurtenances the churches of San Bartolomeo and San Giacomo. The latter, documented since the thirteenth century, was at the foot of the hill where the castle stood, along the ancient route of the Via Flaminia. Perfectly preserved until the middle of this century, it's now reduced to a pile of rubble because on several occasions it was used as a stone quarry.