 It was briefly occupied by the Teutonic Knights in 1339 before reverting to Poland.In 1359 it received municipal rights from Archbishop Jarosław.Shortly after a defensive castle was built which survived until 1721.