After a long history of being ruled over by others, Estonia gained their independence in 1918 after the collapse of the Russian Empire. However, in 1940, in the wake of the Molotov–Ribbentrop Pact of 1939, the Soviet Union occupied Estonia and annexed the country.