It was the famous Harold Bluetooth who, around 980, unified the many petty kingdoms in what is now Denmark, and created a single state. Embracing Christianity, he forged bonds with western and central Europe, particularly the Holy Roman empire and the papacy. The first was necessary as it was a neighbouring state; the second was to further strengthen his position at home, with the help of the clergy. When England broke away from Danish control after the death of Canute the Great (1035), Denmark suffered internal disorder and was frequently raided by vikings from Norway. However, Canute’s nephew Sweyn Estridson (1020-1074) re-established strong royal authority.
The mid 12th century was a difficult time for the kingdom of Denmark. Civil wars rocked the land and created much strife. Eventually, Valdemar the Great (1131-82), gained control of the kingdom, stabilising it and reorganizing the administration. During Valdemar’s reign, a castle was built in the village of Havn, leading eventually to the foundation of Copenhagen, the modern capital of Denmark. Denmark was transformed in this time into a major power in the Baltic Sea, competing with the Hanseatic League, the Counts of Holstein, and the Teutonic Knights for trade, territory, and influence throughout the area. Valdemar and his successors launched various ‘crusades’ to claim territories, notably modern Estonia.
By the late 13th century, royal power had waned, and the nobility forced the king to grant a charter, considered Denmark's first constitution. A weakened Denmark was of great benefit to both the Hanseatic League and the Counts of Holstein. These counts gained control of large portions of Denmark because the king would grant them fiefs in exchange for money to finance royal operations. Consequently, by the 1320s the king was largely bound by the wishes of these counts, who by then owned most of Denmark.
The kingdom continued to fall apart; the territory of Scania passed for a while to the King of Sweden. In 1340 the throne fell to Valdemar Atterdag, or "New Day." He was a skilled politician and was able to reunite the old kingdom of Denmark by turning the counts against each other. His continued efforts to expand the kingdom after 1360 brought him into open conflict with the Hanseatic League. He conquered Gotlandia, much to the displeasure of the League, since Visby, an important trading town, was located there. Their alliance with Sweden to attack Denmark was initially a fiasco since Danish forces captured a large Hanseatic fleet, and ransomed them back for an enormous sum. Luckily for the League the Jutland Nobles revolted against the heavy taxes levied to fight the expansionist war in the Baltic; the two forces worked against the king, forcing him into exile in 1370. For several years, the Hanseatic League controlled the fortresses on "the sound" between Scania and Zealand.
Margaret I was the daughter of Valdemar Atterdag. She was married to Håkon VI of Norway in an attempt to join the two kingdoms, along with Sweden, since Håkon was related to the Swedish royal family. Originally her son, Olaf III was intended to rule the three kingdoms, but due to his early death she took on the role. During her life, the three kingdoms of Denmark, Norway, and Sweden (including the Faroe Islands, as well as Iceland, Greenland, and present-day Finland) were unified under her capable rule, in what was called the Kalmar Union, made official in 1397.
Her successor, Eric of Pomerania, lacked his predecessor's skill and was directly responsible for the breakup of the Kalmar Union. However, there was still some enthusiasm for the idea, so when Christopher of Bavaria, a distant relative came to the throne, he managed to be elected in all three kingdoms, briefly reuniting Scandinavia. The Swedish nobility grew increasingly unhappy with Danish rule and the union soon became merely a legal concept with little practical application.