In accordance with a secret protocol within the Molotov–Ribbentrop Pact of 1939 that divided Europe into German and Soviet spheres of influence, the Soviet Army entered eastern Poland in September 1939, and then coerced Estonia, Latvia, and Lithuania into mutual assistance treaties which granted them the right to establish military bases in these countries. In June 1940, the Red Army occupied all of the territory of Estonia, Latvia, and Lithuania, and installed new, pro-Soviet governments in all three countries. Following elections (in which only pro-communist candidates were allowed to run), the newly elected parliaments of the three countries formally applied to join the Soviet Union in August 1940 and were incorporated into it as the Estonian, Latvian, and Lithuanian Soviet Socialist Republics.