 It was granted town rights in 1392 by Polish King Władysław II Jagiełło and new privileges in 1542 and 1620.It was annexed by Prussia in the Second Partition of Poland in 1793.In 1807 regained by the Poles as part of the short-lived Duchy of Warsaw, in 1815 it became part of Congress Poland, later forcibly integrated with Imperial Russia.