The history of the fortress dates back at least to Roman times. In its present form, however, it is a work of the great engineer Francesco di Giorgio Martini from Siena, who was entrusted by Federico da Montefeltro, Duke of Urbino, to redesign the fortress and adapt it to the new demands of war. The fort of San Leo became an emblem of the perfect combination of nature and art. In 1502, Cesare Borgia, supported by his father Pope Alexander VI, succeeded in taking the fortress, but after the death of the Pope (1503), duke Guidobaldo da Montefeltro returned in possession of the town. Since 1631 the fortress became a prison: among others, it hosted Cagliostro (who died there)and Felice Orsini.