 The seat of a bishop until the 11th century, Trevi was a Lombard gastaldate, then, in the early 13th century, freed itself of outside rulership to become a free commune.It generally allied itself with Perugia in order to defend itself from nearby Spoleto, and fought several wars with other neighboring communes, with varying outcomes, including invasion by Spoleto in the 14th century and a brief but unhappy rule of the Trinci warlords of Foligno.In 1438 Trevi passed under the temporal rule of the Church as part of the legation of Perugia, and thenceforth its history merges first with that of the States of the Church, then (1860) with the united Kingdom of Italy.