The Soviet Union signed a non-aggression pact with Nazi Germany on 23 August 1939. In addition to stipulations of non-aggression, the treaty included a secret protocol that divided territories of Romania, Poland, Lithuania, Latvia, Estonia, and Finland into German and Soviet "spheres of influence", anticipating potential "territorial and political rearrangements" of these countries.In October and November 1940, German-Soviet talks about the potential of joining the Axis took place in Berlin, nothing came from the talks since Hitler's Ideological goal was Lebensraum in the East.
Germany invaded Poland on 1 September 1939 starting World War II, Stalin waited until September 17th before launching his own invasion of Poland. Part of the Karelia and Salla regions of Finland were annexed by the Soviet Union after the Winter War. This was followed by Soviet annexations of Estonia, Latvia, Lithuania, and parts of Romania (Bessarabia, northern Bukovina and the Hertza region). It was known at the Nuremberg trials the existence of the secret protocol of the German–Soviet pact regarding the planned divisions of these territories. The invasion of Bukovina violated the Molotov–Ribbentrop Pact, as it went beyond the Soviet sphere of influence agreed with the Axis.
On 22 June 1941, Hitler launched an invasion of the Soviet Union. Stalin was confident that the total Allied war machine would eventually stop Germany, and with Lend Lease from the West, the Soviets stopped the Wehrmacht some 30 kilometers from Moscow. Over the next four years, the Soviet Union repulsed Axis offensives, such as at the Battle of Stalingrad and the Battle of Kursk, and pressed forward to victory in large Soviet offensives, such as the Vistula–Oder Offensive.
The bulk of Soviet fighting took place on the Eastern Front—including a continued war with Finland—but it also invaded Iran (August 1941) in cooperation with the British and late in the war attacked Japan (August 1945), with which the Soviets had border wars earlier up until in 1939.
Stalin met with Winston Churchill and Franklin D. Roosevelt at the Tehran Conference and began to discuss a two-front war against Germany and the future of Europe after the war. Berlin finally fell in April 1945. Fending off the German invasion and pressing to victory in the East required a tremendous sacrifice by the Soviet Union, which suffered the highest casualties in the war, losing more than 20 million citizens .