During the Swedish invasion of Poland, in 1656, the castle was visited by King John II Casimir (1609-1672). In 1657, it was unsuccessfully besieged by the Swedish ally, George II Rákóczi. In the late 17th century, after the 1688 fire, the castle was restored by Tylman van Gameren, a Dutch-born Polish architect and engineer who, at the age of 28, settled in Poland and worked for wealthy magnates. Tylman left behind a lifelong legacy of buildings that are regarded as gems of Polish Baroque architecture. In Łańcut he transformed the former castle into a palace, simultaneously adding bulbous cupolas to the side towers, which are the most characteristic aspect of the castle's architecture.