Signs of settlement dating back to the Roman Empire era have been found. In the early Middle Ages a fortified settlement of the Prussian people existed at the site, conquered by the Teutonic Knights in 1236. City rights were granted to the settlement in 1416.
In 1466 the town with other western Prussian territory passed to the crown of Poland as part of Royal Prussia. As part of Poland, the town functioned as a seat of Sztum powiat in Malbork Voivodeship (1466-1772) and a place to hold local court sessions. In 1635 the Treaty of Stuhmsdorf was signed in the village of Stuhmsdorf (now Sztumska Wies, just south of the city of Sztum).
According to the Treaty of Versailles after World War I the inhabitants were asked whether they want to remain in Germany or join the new Second Polish Republic in the East Prussian plebiscite on 11 July 1920, 19,984 votes were given to remain in Germany, 4,904 votes for Poland. Based on that result Stuhm was included in the Regierungsbezirk Marienwerder within East Prussia.
At the end of World War II, the town, along with the rest of southern East Prussia, was assigned to Poland by the Potsdam Conference under territorial changes proposed by the USSR. The city was resettled by Poles, many of them, expellees from Polish areas annexed by the Soviet Union.
Number of inhabitants by year