After their defeat at the Battle of Grunwald, the Teutonic Knights according to the 1411 Peace of Thorn had to pay large contributions to the Polish kings, which strongly affected the public budget. In view of rising taxes, several local nobles and Hanseatic cities in 1440 established the Prussian Confederation at Marienwerder (Kwidzyn) protesting against the Order's internal and financial policies. The Confederation was led by the citizens of Danzig, Elbing, and Thorn. The gentry from Chełmno Land and Pomerelia participated as well. Grand Master Ludwig von Erlichshausen demanded the dissolution and in 1453 searched for help from Pope Nicholas V and Emperor Frederick III. In turn, in February 1454, the Confederation sent a delegation, under Johannes von Baysen, to King Casimir IV Jagiellon of Poland, to ask him for support against the Teutonic Order's rule and for incorporation of their homeland into the Kingdom of Poland. In this act, Prussian delegates declared the Polish king the only true heir of those lands, parts of which were earlier illegally separated from Poland. After some hesitation and negotiating the exact conditions of incorporation on 6 March 1454, the Royal Chancellery issued the Act of Incorporation that met the requests of the Prussian estates represented by the Confederation.[7]

After the Prussian Confederation pledged allegiance to Casimir on 6 March 1454, the Thirteen Years' War ("War of the Cities") began. King Casimir IV Jagiellon appointed Baysen as the first war-time governor of Royal Prussia. On 28 May 1454 the king took an oath of allegiance from the citizens of Toruń and in June a similar oath from the citizens of Elbing and Königsberg.[7]

The rebellion also included major cities from the eastern part of the Order's lands, such as Kneiphof (Knipawa), later a part of Königsberg. Though the Knights were victorious at the 1454 Battle of Chojnice/Konitz, they were not able to finance further mercenaries in order to reconquer the castles occupied by the insurgents. Thirteen years of attrition warfare ended in October 1466 with the Second Peace of Thorn (1466), which provided for the Order's cession to the Polish Crown of its rights over the western half of Prussia, including Pomerelia and the districts of Elbing, Marienburg, and Chełmno.

According to the 1454 Incorporation Statute issued by King Casimir IV, Royal Prussia enjoyed substantial autonomy as part of the Crown of Poland: it had its own treasury, monetary unit, and armies.[citation needed] It was governed by a council, subordinate to the Polish king, whose members were chosen from local lords and wealthy citizens (ius indigenatus). Prussians had also seats provided for them in the Sejm (Polish Diet), but they chose not to use this right until the Union of Lublin. Thorn, Elbing, and Danzig (Danzig law) gained privileges similar to the status of a Free imperial city.