Already weakened during the 18th century, by the mid-1790s the Polish–Lithuanian Commonwealth had twice been partitioned by its neighbors: Russia, the Habsburg empire and Prussia. In 1791, the Austrian and Holy Roman Emperor Joseph II changed the status of Kazimierz as a separate city and made it into a district of Kraków. The richer Jewish families began to move out. However, because of the injunction against travel on the Sabbath, most Jewish families stayed relatively close to the historic synagogues. In 1794, Tadeusz Kościuszko initiated an unsuccessful insurrection in the town's Main Square which, in spite of his victorious Battle of Racławice against a numerically superior Russian army, resulted in the third and final partition of Poland. In 1809, Napoleon Bonaparte captured former Polish territories from Austria and made the town part of the Duchy of Warsaw. Following Napoleon's defeat, the 1815 Congress of Vienna restored the pre-war boundaries but also created the partially independent Free City of Kraków. An insurrection in 1846 failed, resulting in the city being annexed by Austria under the name the Grand Duchy of Kraków (, ).