Immediately after the German invasion of Poland in 1939, which marked the beginning of World War II, the Soviet Union invaded the eastern regions of the Second Polish Republic, which Poles referred to as the "Kresy", and annexed territories totaling 201,015 square kilometres (77,612 sq mi) with a population of 13,299,000 inhabitants including Belarusians, Ukrainians, Poles, Jews, Czechs and others.
Most of these territories remained within the Soviet Union in 1945 as a consequence of European-wide territorial rearrangements configured during the Tehran Conference of 1943. Poland was compensated for this territorial loss with the prewar German eastern territories much of which had been devastated during the war, and had been looted and pillaged by the Red Army. Communist Poland described the territories as the "Recovered Territories". The number of Poles in the Kresy in the year 1939 was around 5.274 million, but after ethnic cleansing in 1939-1945 by the Nazi Germany, Soviet Union and Ukrainian nationalist forces consisted of approximately 1.8 million inhabitants. The post-World War II territory of Poland was significantly smaller than the pre-1939 land areas, shrinking by some 77,000 square kilometres (30,000 sq mi) (roughly equaling that of the territories of Belgium and the Netherlands combined).
Early in the morning of August 24, 1939, the Soviet Union and Nazi Germany signed a 10-year non-aggression pact, called the Molotov–Ribbentrop pact. Most notably, the pact contained a secret protocol, revealed only after Germany's defeat in 1945, according to which the states of Northern and Eastern Europe were divided into German and Soviet "spheres of influence". In the North, Finland, Estonia and Latvia were assigned to the Soviet sphere. Poland was to be partitioned in the event of its "political rearrangement"—the areas east of the Narev, Vistula and San Rivers going to the Soviet Union while Germany would occupy the west. Initially annexed by Poland in a series of wars between 1918 and 1921 (primarily the Polish-Soviet War), these territories had mixed urban national populations with Poles and Ukrainians being the most numerous ethnic groups, with significant minorities of Belarusians and Jews. Much of this rural territory had its own significant local non-Polish majority (Ukrainians in the south and Belarusians in the North).