records during Ivan the Terrible's reign, argued that Tartu's "founding" by Ancient Rus' justified Russia's contemporary territorial claims to the region. In the effect of the Truce of Jam Zapolski of 1582, the city along with southern regions of Livonian Confederation became part of the Polish–Lithuanian Commonwealth. In 1598 it became the capital of the Dorpat Voivodeship of the Duchy of Livonia. A Jesuit grammar school "Gymnasium Dorpatense" was established in 1583. In addition, a translators' seminary was organized in Tartu and the city received its red and white flag from the Polish king Stephen Báthory. The activities of both the grammar school and the seminary were stopped by the Polish–Swedish War. Already in late 1600 the forces of Charles IX of Sweden besieged the city defended by three banners of reiters and the city's burghers. Despite repeated assaults, the Swedes could not enter the city. Finally in 1601 Capt. Hermann Wrangel switched sides, assaulted the castellan and opened the gates for the Swedish forces. The town was retaken by Polish–Lithuanian Commonwealth on 13 April 1603 following a brief siege led by hetman Jan Karol Chodkiewicz; roughly 1000 Swedish soldiers surrendered and were escorted to Tallinn. In the effect of yet another Polish-Swedish War, in 1625 Tartu was once again captured by Sweden, this time for good. In the effect of the 1629 Truce of Altmark the city became part of the Dominions of Sweden, which led to the foundation of the University of Tartu in 1632 by king Gustavus Adolphus of Sweden. Imperial Russia In 1704 the town was taken by the Russian army in the presence of tsar Peter the Great himself. As a result, around a quarter of the town and much of the fortifications were damaged. In 1708 the remainder of the fortifications and houses, including the remains of bishops castle, were blown up, all movable property was looted and all citizens deported to Russia. With the Treaty of Nystad in 1721, the city became part of the Russian Empire and was known as Derpt. Fires in the 18th century destroyed much of the medieval architecture, the Great Fire of Tartu in 1775 removed most of the buildings in the centre. The city was rebuilt along Late Baroque and Neoclassical lines including the Tartu Town Hall which was built between 1782 and 1789. In 1783 the city became the centre of Derpt uyezd within the Governorate