https://en.wikipedia.org/wiki/Molotov%E2%80%93Ribbentrop_Pact
The Molotov–Ribbentrop Pact was a non-aggression pact between Nazi Germany and the Soviet Union that enabled those two powers to partition Poland between them. The pact was signed in Moscow on 23 August 1939 by German Foreign Minister Joachim von Ribbentrop and Soviet Foreign Minister Vyacheslav Molotov and was officially known as the Treaty of Non-Aggression between Germany and the Union of Soviet Socialist Republics. Unofficially it has also been referred to as the Hitler–Stalin Pact, Nazi–Soviet Pact or Nazi–Soviet Alliance (although it was not a formal alliance).
Its clauses provided a written guarantee of peace by each party towards the other and a commitment that declared that neither government would ally itself to or aid an enemy of the other. In addition to the publicly-announced stipulations of non-aggression, the treaty included the Secret Protocol, which defined the borders of Soviet and German spheres of influence across Poland, Lithuania, Latvia, Estonia and Finland. The secret protocol also recognized the interest of Lithuania in the Vilnius region, and Germany declared its complete disinterest in Bessarabia. The rumour of the existence of the Secret Protocol was proved only when it was made public during the Nuremberg Trials.
Soon after the pact, Germany invaded Poland on 1 September 1939. Soviet leader Joseph Stalin ordered the Soviet invasion of Poland on 17 September, one day after a Soviet–Japanese ceasefire came into effect after the Battles of Khalkhin Gol. After the invasions, the new border between the two countries was confirmed by the supplementary protocol of the German–Soviet Frontier Treaty. In March 1940, parts of the Karelia and Salla regions, in Finland, were annexed by the Soviet Union after the Winter War. That was followed by the Soviet annexation of Estonia, Latvia, Lithuania and parts of Romania (Bessarabia, Northern Bukovina and the Hertza region). Concern for ethnic Ukrainians and Belarusians had been used as pretexts for the Soviets' invasion of Poland. Stalin's invasion of Bukovina in 1940 violated the pact since it went beyond the Soviet sphere of influence that had been agreed with the Axis.
The territories of Poland annexed by the Soviet Union after the 1939 Soviet invasion east of the Curzon line remained in the Soviet Union after the war ended and are now in Ukraine and Belarus. Vilnius was given to Lithuania. Only Podlaskie and a small part of Galicia east of the San River, around Przemyśl, were returned to Poland. Of all the other territories annexed by the Soviet Union in 1939 to 1940, those detached from Finland (Western Karelia, Petsamo), Estonia (Estonian Ingria and Petseri County) and Latvia (Abrene) remain part of Russia, the successor state to the Russian SSR after the dissolution of the Soviet Union in 1991. The territories annexed from Romania had also been integrated into the Soviet Union (as the Moldavian SSR or oblasts of the Ukrainian SSR). The core of Bessarabia now forms Moldova. Northern Bessarabia, Northern Bukovina and Hertza now form the Chernivtsi Oblast of Ukraine. Southern Bessarabia is part of the Odessa Oblast, which is also in Ukraine.
The pact was terminated on 22 June 1941, when Germany launched Operation Barbarossa and invaded the Soviet Union, in pursuit of the ideological goal of Lebensraum. After the war, Ribbentrop was convicted of war crimes at the Nuremberg trials and executed. Molotov died in 1986.