 In 1372 the town was surrounded by a defensive wall with two entrance gates.In 1440 the town joined the Prussian Confederation, at which request in 1454 King Casimir IV Jagiellon signed the act of incorporation of the region to Poland.During the Thirteen Years’ War (1454–1466), the town was successfully defended against the Teutonic Knights, until 1461.