After the Partitions of Poland in 1795, the area was annexed by the Russian Empire. After World War I, the area became part of the restored Republic of Poland. In 1929, the Polish authorities ordered reconstruction and restoration of the Trakai Island Castle. The works in the Upper castle were almost complete in 1939, when the Invasion of Poland started and the area was soon annexed by the Soviet Union, then by Nazi Germany during Operation Barbarossa. During the war, more than 5,000 Jews from the Trakai region were murdered by the Nazis. In 1944, during Operation Tempest, the town was liberated by joint forces of the underground Polish Home Army and Soviet partisans. After World War II it was again annexed by the Soviet Union and made part of the Lithuanian SSR in the Soviet Union; subsequently many of the city's and area's ethnic Polish inhabitants left for the recovered Territories of the Polish People's Republic.