The Second Peace of Thorn in October 1466 ended the war and provided for the Teutonic Order's cession of its rights over the western half of its territories to the Polish Kingdom, which became the Polish province of Royal Prussia and the remaining part of the Order's land became a fief and protectorate of Poland, considered part of one and indivisible Kingdom of Poland. In accordance to the peace treaty, from now on, every Grand Master was obliged to swear an oath of allegiance to the reigning Polish king within six months of taking office, and any new territorial acquisitions by the Teutonic Order, also outside Prussia, would also be incorporated into Poland. The Grand Master of the Teutonic Order became a prince and counselor of the Polish king and the Kingdom of Poland.