In 1333 the town's name is mentioned as „Waldinborg“. In 1373, along with the region it became part of the Czech Crown Lands, ruled by the Luxembourg dynasty. In 1402, the Luxembourgs reached an agreement with Poland in Kraków, according to which Poland was to purchase and re-incorporate the region, but eventually the Luxembourgs sold it to the Teutonic Order. It was captured by joint Polish-Czech forces in 1433, during the Polish–Teutonic War (1431–1435). When another Polish-Teutonic war broke out in 1454, the Teutonic Knights sold the region to the Margraviate of Brandenburg in order to raise funds for war. The prosperity of the town came from agriculture, clothmaking and trade. It was located on the trade route connecting Poznań and Szczecin, and despite its annexation from Poland, it still had strong ties with Greater Poland. After the Thirty Years' War (1618–1648) many Poles settled in the town, and until 1660 local merchants were exempt from tariffs in trade with Poland. From the 18th century it was part of the Kingdom of Prussia and from 1871 also Germany, until 1945.