Gavi was built by incorporating a pre-existing castle built, according to legend, at the time of the Saracen occupations and anointed by Princess Gavia who had established her residence in that location. The first document that testifies to the existence of the castle is a notarial act dating back to the year 973.
The castle remained the property of the Genoese, albeit with ups and downs, at least until 1418 when it passed first to the Milanese Lordship of the Visconti, then to the Fregoso family and finally to the Alexandrian Guasco, lords of Francavilla.
Over the centuries the transformation from castle to fort has been slow but constant: the first radical interventions on the original structure were made in 1540 by the military engineer in the service of the Republic Giovanni Maria Olgiati.Disarmed in 1859, the fort was transformed into a civil penitentiary. During the First World War it was used as a prison camp for the Austro-Hungarians, while during the Second World War it was used as a prison camp for Anglo-American officers. The fortress can be visited in the various main rooms.
References:Ogrodzieniec Castle is a ruined medieval castle originally built in the 14th–15th century by the W³odkowie Sulimczycy family. Established in the early 12th century, during the reign of Boles³aw III Wrymouth, the first stronghold was razed by the Tatars in 1241. In the mid-14th century a new gothic castle was built here to accommodate the Sulimczycy family. Surrounded by three high rocks, the castle was well integrated into the area. The defensive walls were built to close the circuit formed by the rocks, and a narrow opening between two of the rocks served as an entrance.
In 1470 the castle and lands were bought by the wealthy Cracovian townsmen, Ibram and Piotr Salomon. Then, Ogrodzieniec became the property of Jan Feliks Rzeszowski, the rector of Przemy¶l and the canon of Cracow. The owners of the castle about that time were also Jan and Andrzej Rzeszowskis, and later Pilecki and Che³miñski families. In 1523 the castle was bought by Jan Boner.