In 1440, the city participated in the foundation of the Prussian Confederation which was an organisation opposed to the rule of the Teutonic Knights. The organisation in its complaint of 1453 mentioned repeated cases in which the Teutonic Knights imprisoned or murdered local patricians and mayors without a court verdict. Upon the request of the organisation King Casimir IV of Poland reincorporated the territory to the Kingdom of Poland in 1454. This led to the Thirteen Years' War between Poland and the State of the Teutonic Order (1454–1466). Since 1454, the city was authorized by the King to mint Polish coins. The local mayor pledged allegiance to the King during the incorporation in March 1454 in Kraków, and the city again solemnly pledged allegiance to the King in June 1454 in Elbląg, recognizing the prior Teutonic annexation and rule as unlawful. On 25 May 1457 the city gained its rights as an autonomous city.