On 16 February 1918, Lithuania was re-established as a democratic state. It remained independent until the outset of World War II, when it was occupied by the Soviet Union under the terms of the Molotov–Ribbentrop Pact. Following a brief occupation by Nazi Germany after the Nazis waged war on the Soviet Union, Lithuania was again absorbed into the Soviet Union for nearly 50 years. In 1990–1991, Lithuania restored its sovereignty with the Act of the Re-Establishment of the State of Lithuania. Lithuania joined the NATO alliance in 2004 and the European Union as part of its enlargement in 2004.