After the Munich Agreement, the Soviet Union pursued a rapprochement with Nazi Germany. On 23 August 1939, the Soviet Union signed a non-aggression pact with Germany which included a secret protocol that divided Eastern Europe into German and Soviet spheres of influence, anticipating potential "territorial and political rearrangements" of these countries. Germany invaded Poland on 1 September 1939, starting World War II. The Soviets invaded eastern Poland on 17 September. Following the Winter War with Finland, the Soviets were ceded territories by Finland. This was followed by annexations of the Baltic states and parts of Romania.
On 22 June 1941, Adolf Hitler launched Operation Barbarossa, an invasion of the Soviet Union with the largest invasion force in history, resulting in large battles and horrific atrocities. This offensive comprised three army groups. The city of Leningrad was besieged while other major cities fell to the Germans. Despite initial successes, the German offensive ground to a halt in the Battle of Moscow, and the Soviets launched a counteroffensive, pushing the Germans back. The failure of Operation Barbarossa reversed the fortunes of Germany, and Stalin was confident that the Allied war machine would eventually defeat Germany. The Soviet Union repulsed Axis attacks, such as in the Battle of Stalingrad and the Battle of Kursk, which marked a turning point in the war. The Western Allies provided support to the Soviets in the form of Lend-Lease as well as air and naval support. Stalin met with Winston Churchill and Franklin D. Roosevelt at the Tehran Conference and discussed a two-front war against Germany and the future of Europe after the war. The Soviets launched successful offensives to regain territorial losses and began a push to Berlin. The Germans unconditionally surrendered in May 1945 after Berlin fell.