The background of the occupation of the Baltic states covers the period before the first Soviet occupation on 14 June 1940, stretching from independence in 1918 to the Soviet ultimatums in 1939–1940. The Baltic states gained their independence during and after the Russian revolutions of 1917; Lenin's government allowed them to secede. They managed to sign non-aggression treaties in the 1920s and 1930s. Despite the treaties, the Baltic states were forcibly incorporated into the Soviet Union in 1940 in the aftermath of the German–Soviet pact of 1939.