After the joint German-Soviet invasion of Poland, which started World War II in 1939, it was occupied by Germany until 1945. Towards the end of World War II, the town was occupied by the Red Army and was restored to Poland in its entirety. The remaining German population was expelled in accordance with the Potsdam Agreement.