Neumark were ravaged by the Hussites during the Hussite Wars. Some Teutonic Knights were sent to battle the invaders but were defeated by the Bohemian infantry. The Knights also sustained a defeat in the Polish-Teutonic War (1431–1435). In 1440, the Prussian Confederation was founded by gentry and burghers of the State of the Teutonic Order. In 1454, it rose up against the Order and asked Polish King Casimir IV Jagiellon to incorporate the region into the Kingdom of Poland, to which the King agreed and signed an act of incorporation in Kraków. Mayors, burghers and representatives from the region pledged allegiance to the Polish King during the incorporation in March 1454 in Kraków. This marked the beginning of the Thirteen Years' War between the Teutonic Order and Poland. The main cities of the incorporated territory were authorized by Casimir IV to mint Polish coins. Much of Prussia was devastated in the war, during the course of which the Order returned Neumark to Brandenburg in 1455 to raise funds for war. Because Marienburg Castle was handed over to mercenaries in lieu of their pay, and eventually passed to Poland, the Order moved its base to Königsberg in Sambia. In the Second Peace of Thorn (1466), the defeated Order renounced any claims to the territories of Gdańsk/Eastern Pomerania and Chełmno Land, which were reintegrated with Poland, and the region of Elbląg and Malbork, and the Prince-Bishopric of Warmia, which were also recognized as part of Poland, while retaining the eastern territories in historic Prussia, but as a fief and protectorate of Poland, also considered an integral part of "one and indivisible" Kingdom of Poland. From now on, every Grand Master of the Teutonic Order was obliged to swear an oath of allegiance to the reigning Polish king within six months of taking office. The Grand Master became a prince and counselor of the Polish king and the Kingdom of Poland. After the Polish–Teutonic War (1519–1521), the Order was completely ousted from Prussia when Grand Master Albert of Brandenburg converted to Lutheranism in 1525. He secularized the Order's remaining Prussian territories and assumed from his uncle Sigismund I the Old, King of Poland, the hereditary rights to the Duchy of Prussia as a personal vassal of the Polish Crown, the Prussian Homage. Ducal Prussia retained its currency, laws and faith. The aristocracy was not present in the Sejm. Although it had lost control