The Kalmar Union was created by Queen Margaret I of Denmark, who married King Haakon VI of Norway. Their son Olav became heir to both Denmark and Norway, creating a personal union between the two countries. Unfortunately, Olav died before he was old enough to ascend the throne, and Margaret was made regent of both kingdoms in his stead in 1388-1389.
Margaret was also elected regent of some parts of Sweden and in 1389 her combined Danish and Swedish troops defeated the Swedish king, Albert of Mecklenberg, securing control over Sweden. Margaret’s grand-nephew Erick, already king of Norway, succeeded the thrones of Denmark and Sweden in 1396.
The union was formalized in 1397 with the Treaty of Kalmar, which outlined an eternal union between the three countries under one king, though the countries were to be governed separately.