In 1793 as a consequence of the Second Partition of Poland the town became part of the Kingdom of Prussia. In 1807 it became part of the Polish Duchy of Warsaw, then in 1815 part of Congress Poland within the Russian Empire. In 1846 the section of the Warsaw–Vienna railway that ran through the town opened, providing a railway connection to Warsaw. Inhabitants took part in the November and January uprisings against Russia. After the latter anti-Polish repressions, including Russification policies, intensified. The Russian administration expelled Franciscan monks from the town.