San Leo stands on an imposing rhomboid rock with cliff faces precipitating to the valley floor, in the centre of the Marecchia Valley, in the heart of historical Montefeltro.
Ever since prehistoric times, this extraordinary natural location has served the double function of a natural fortress and an inaccessible and therefore sacred height.
The medieval centre retains all its Romanic buildings including the church, cathedral and bell tower.
The Italian king Berengario was besieged within the original early medieval town by Otto I of Germany between 961 and 963. The town was expanded between the 13th and 14th centuries after the Malatesta family seized San Leo from the dukes of Montefeltro.
The medieval keep, defended by its square Malatestian towers, was redesigned by the Siennese architect Francesco di Giorgio Martini on the wishes of Federico of Montefeltro in 1479.
By 1788, the prisons of the fortress of San Leo were totally insalubrious in size and location and one of the bulwarks was on the point of collapse, Pius VII therefore nominated Giuseppe Valadier as architect to the Vatican, and charged him with making the necessary improvements to the entire structure. Giuseppe Balsamo, better known as Alessandro Count of Cagliostro, and one of the most enigmatic and fascinating adventurers of the age of Enlightenment, was imprisoned here from 1791 until his death on the 26th August 1795.