Denmark became a major North European power During the Viking period (9th – 11th centuries), and in the late 14th century Sweden, Norway, Finland, Iceland, and Greenland were united under the Danish rule. Sweden and Finland withdrew from the union in the 1500s, Norway was lost to Sweden in 1814, and Iceland gained independence following World War I. The Danish liberal movement gained momentum in the 1830s, and in 1849 Denmark became a constitutional monarchy. Denmark remained neutral during World War I. Despite its declaration of neutrality at the beginning of World War II, it was invaded and occupied by Germany from 1940 to 1945. Denmark has evolved into a modern, prosperous nation with extensive welfare system and has participated in the general political and economic integration of Europe. It joined NATO in 1949 and the EEC (now the EU) in 1973. However, the country has opted out of certain elements of the EU's Maastricht Treaty, including the European Economic and Monetary Union (EMU) and European defense cooperation.