In 1789 after the death of Kraków Bishop Kajetan Sołtyk and after the partition of Poland the castle belonged to Emperor Joseph II. In 1800 fire destroyed most of the buildings. Since then the castle stayed inhabited. During the January Uprising 1863 the troops of general Marian Langiewicz sheltered in the castle.