The Second Polish Republic was established in 1918 and existed as an independent state until 1939, when Nazi Germany and the Soviet Union invaded Poland, marking the beginning of World War II. Millions of Polish citizens of different faiths or identities perished in the course of the Nazi occupation of Poland between 1939 and 1945 through planned genocide and extermination. A Polish government-in-exile nonetheless functioned throughout the war and the Poles contributed to the Allied victory through participation in military campaigns on both the eastern and western fronts. The westward advances of the Soviet Red Army in 1944 and 1945 compelled Nazi Germany's forces to retreat from Poland, which led to the establishment of a satellite communist country, known from 1952 as the Polish People's Republic.