On 23 August 1939, Germany and the Soviet Union signed the Molotov–Ribbentrop Pact, which contained a secret protocol dividing eastern Europe into spheres of influence. Germany's invasion of its part of Poland under the Pact eight days later triggered the beginning of World War II. By the end of 1941, Germany occupied a large part of Europe and its military forces were fighting the Soviet Union, nearly capturing Moscow. However, crushing defeats at the Battle of Stalingrad and the Battle of Kursk devastated the German armed forces. This, combined with Western Allied landings in France and Italy, led to a three-front war that depleted Germany's armed forces and resulted in Germany's defeat in 1945.