 It was the most westward fortification, and was meant to hold off any invasion coming to Lesser Poland from Bohemian or Silesian lands.In 1364 the castle was visited by Charles IV, Holy Roman Emperor.In 1588, Maximilian III, Archduke of Austria, was held prisoner in here, after his defeat in the War of the Polish Succession (1587–1588).