In 1441 both the town and the local Teutonic county official joined the Prussian Confederation, which opposed Teutonic rule, and upon the request of which King Casimir IV Jagiellon incorporated the territory to the Kingdom of Poland in 1454. The castle, which initially remained in the hands of the Teutonic Knights, was captured by Poles after a siege in 1454, but later it was taken over by the Teutonic Knights again. In 1466 by the Second Peace of Toruń the town was finally renounced by the Teutonic KnightsGórski, p. 106 and integrated with the Kingdom of Poland. As part of Poland, the town functioned as a seat of the Sztum County in Malbork Voivodeship and a place to hold the voivodeship's sejmiks (regional court sessions). The Sztum Castle was the seat of the local starosts. In 1552, the town was visited by Polish King Sigismund II Augustus.
