Joseph Stalin came to power in the Soviet Union after Lenin's death in 1922, winning a power struggle for control. In the decades prior to World War 2, Stalin instituted policies like collectivization, industrialization, and purges that strengthened the Soviet Union but also led to famines and gulags. During the war, the Soviet Union initially signed the Molotov-Ribbentrop pact with Nazi Germany in 1939 and invaded neighboring countries, but was then invaded by Germany in 1941 in a massive operation called Operation Barbarossa. After enduring huge losses, the Soviet Union began pushing the Germans back starting in 1943 and eventually took Berlin in 1945, playing a major role in defeating Nazi Germany.