In 1440 the town joined the anti-Teutonic Prussian Confederation, at the request of which King Casimir IV Jagiellon signed the act of incorporation of the region and town to Poland in 1454. In the beginning of the Thirteen Years' War in 1454, the pro-Polish troops took over the local castle. The incorporation of the town to Poland was confirmed in the Second Peace of Toruń in 1466. It was part of the Chełmno Voivodeship and soon afterwards became a centre of local trade and commerce. As such it became one of the seats of the bishops of Chełmno. In 1533 it was razed to the ground by a great fire mentioned by Erasmus of Rotterdam, but it was soon rebuilt and between 1535 and 1539 Nicolaus Copernicus visited the bishop's castle in Lubawa several times. At that time, the castle also housed an astronomical observatory. It was in Lubawa that the decision was made to publish Copernicus' groundbreaking work "De revolutionibus orbium coelestium". In 1545 the town and the castle were yet again destroyed by a fire.