Greece achieved its independence from the Ottoman Empire in 1829. During the second half of the 19th century and the first half of the 20th century, it gradually added neighboring islands and territories with Greek-speaking populations. Following the defeat of communist rebels in 1949, Greece joined NATO in 1952. A military dictatorship, which in 1967 had suspended many political liberties and forced the king to flee the country, was itself overthrown seven years later. Democratic elections in 1974 abolished the monarchy and created a parliamentary republic; Greece joined the EU in 1981.