During the Viking period (9th-11th centuries), Denmark was a great power based on the Jutland Peninsula, the Island of Zealand, and the southern part of what is now Sweden. In the early 11th century, King Canute united Denmark and England for almost 30 years.
Viking raids brought Denmark into contact with Christianity, and in the 12th century, crown and church influence increased. By the late 13th century, royal power had waned, and the nobility forced the king to grant a charter, considered Denmark's first constitution. Although the struggle between crown and nobility continued into the 14th century, Queen Margrethe I succeeded in uniting Denmark, Norway, Sweden, Finland, the Faroe Islands, Iceland, and Greenland under the Danish crown. Sweden and Finland left the union in 1520; however, Norway remained until 1814. Iceland, in a "personal union" under the king of Denmark after 1918, became independent in 1944.
The Reformation was introduced in Denmark in 1536. Denmark's provinces in today's southwestern Sweden were lost in 1658, and Norway was transferred from the Danish to the Swedish crown in 1814, following the defeat of Napoleon, with whom Denmark was allied.
The Danish liberal movement gained momentum in the 1830s, and in 1849 Denmark became a constitutional monarchy. After the war with Prussia and Austria in 1864, Denmark was forced to cede Schleswig-Holstein to Prussia and adopt a policy of neutrality. Toward the end of the 19th century, Denmark inaugurated important social and labor market reforms, laying the basis for the present welfare state.
Denmark remained neutral during World War I. Despite its declaration of neutrality at the beginning of World War II, it was invaded by the Germans in 1940 and occupied until it was liberated by the Allied forces in May 1945. Denmark became a charter member of the United Nations and was one of the original signers of the North Atlantic Treaty.