From the 15th century, the town maintained a close connection with the Order of Saint John (the Knights Hospitaller), who had purchased it from Frederick I, Elector of Brandenburg.
[1] In 1933, German authorities converted the prison into the Sonnenburg concentration camp, in which such anti-Nazi activists as Carl von Ossietzky and Hans Litten were held.
[2] During World War II, Polish defenders of the Poznań citadel were held in the prison after capture during the invasion of Poland in 1939, and in 1944 some of the former fighters in the Warsaw Uprising were incarcerated there.
[1] During the war also Frenchmen, Luxembourgers, Dutchmen, Danes, Norwegians, Belgians, Czechs, Yugoslavs, Slovaks, Bulgarians, Austrians, the Swiss, Estonians, Russians and Spaniards were held in the camp.
During the Potsdam Conference held from 17 July to 2 August 1945 Sonnenburg along with the rest of the recovered territories was awarded to postwar Poland, and renamed legally as Słońsk.
The town was repopulated with the Poles expelled by the Soviet Union from the formerly Polish territories of Kresy Wschodnie, and by settlers from central Poland.