In 1397, Denmark, Norway and Sweden established and formed the Kalmar Union. Following Sweden's departure in 1523, the union was effectively dissolved. From 1536/1537, Denmark and Norway formed a personal union that would eventually develop into the 1660 integrated state called Denmark–Norway. The union lasted until 1814,[3][4] when the Treaty of Kiel decreed that Norway (except Faroe Islands, Iceland, and Greenland) be ceded to Sweden.

The term "Kingdom of Denmark" is sometimes used to include both countries in the period, since the political and economic power emanated from the Danish capital, Copenhagen. These terms cover the "royal territories" of the Oldenburgs as it was in 1460, excluding the "ducal territories" of Schleswig and Holstein. The administration used two official languages, Danish and German, and for several centuries both a Danish and German Chancery existed.[5]

The term "Denmark–Norway" reflects the historical and legal roots of the union. It is adopted from the Oldenburg dynasty's official title. The kings always used the style "King of Denmark and Norway, the Wends and the Goths" (Konge til Danmark og Norge, de Venders og Gothers). Denmark and Norway, sometimes referred to as the "Twin Realms" (Tvillingrigerne) of Denmark–Norway, had separate legal codes and currencies, and mostly separate governing institutions. Following the introduction of absolutism in 1660, the centralisation of government meant a concentration of institutions in Copenhagen. Centralisation was supported in many parts of Norway, where the two-year attempt by Sweden to control Trøndelag resulted in massive losses and a catastrophic failure for the Swedes. This allowed Norway to further secure itself militarily for the future through closer ties with the capital Copenhagen. The term "Sweden–Finland" is sometimes, although with less justification, applied to the contemporary Swedish realm between 1521 and 1809. Finland was never a separate kingdom, and was completely integrated with Sweden, while Denmark was the dominant component in a personal union.

Denmark–Norway maintained numerous colonies from the 17th to 19th centuries over various parts around India. Colonies included the town of Tranquebar and Serampore. The last towns it had control over were sold to the United Kingdom in 1845. Rights in the Nicobar Islands were sold in 1869.

The three kingdoms then united in the Kalmar Union in 1397. Sweden broke out of this union and re-entered it several times, until 1521, when Sweden finally left the Union, leaving Denmark–Norway (including overseas possessions in the North Atlantic and the island of Saaremaa in modern Estonia).

The outbreak of the Northern Seven Years' War in 1563 is mainly attributed[by whom?] to Denmark's displeasure over the dismantling of the Kalmar Union in the 1520s. When the Danish king Christian III (reigned 1534–1559) included the traditionally Swedish insignia of three crowns into his own coat of arms, the Swedes interpreted this as a Danish claim over Sweden. In response Erik XIV of Sweden (reigned 1560–1568) added the insignia of Norway and Denmark to his own coat of arms.

After Swedish king Erik introduced obstacles in an attempt to hinder trade with Russia, Lübeck and the Polish–Lithuanian Commonwealth joined Denmark in a war alliance. Denmark then carried out some naval attacks on Sweden, which effectively started the war. After seven years of fighting, the conflict concluded in 1570 with a status quo ante bellum.

Because of Denmark–Norway's dominion over the Baltic Sea (dominium maris baltici) and the North Sea, Sweden had the intention of avoiding paying Denmark's Sound Toll. Swedish king Charles IX's way of accomplishing this was to try to set up a new trade route through Lapland and northern Norway. In 1607 Charles IX declared himself "King of the Lapps in Nordland", and started collecting taxes in Norwegian territory.

Denmark and King Christian IV of Denmark protested against the Swedish actions, as they had no intentions of letting another independent trade route open, Christian IV also had an intent of forcing Sweden to rejoin its union with Denmark. In 1611 Denmark finally invaded Sweden with 6000 men and took the city of Kalmar. On January 20, 1613, the Treaty of Knäred was signed in which Norway's land route from Sweden was regained by incorporating Lapland into Norway, and Swedish payment of a high ransom of 1 million silver riksdaler for two fortresses which Denmark had taken in the war. However, Sweden achieved an exemption from the Sound Toll, which had only previously been secured by Britain and Holland.

Not long after the Kalmar war, Denmark–Norway got involved in another greater war, in which they fought together with the mainly north German and other Protestant states against the Catholic states led by German Catholic League.

Christian IV sought to become the leader of the north German Lutheran states, however following the Battle of Lutter in 1626 Denmark met a crushing defeat. This led to most of the German Protestant states ceasing their support for Christian IV. After another defeat at the Battle of Wolgast and following the Treaty of Lübeck in 1629, which forbade Denmark from future intervening in German affairs, Denmark's participation in the war came to an end.

Sweden was very successful during the Thirty Years' War, while Denmark was a failure. Sweden saw an opportunity of a change of power in the region. Denmark–Norway had a threatening territory surrounding Sweden, and the Sound Dues were a continuing irritation for the Swedes. In 1643 the Swedish Privy Council determined Swedish territorial gain in an eventual war against Denmark–Norway to have good chances. Not long after this, Sweden invaded Denmark–Norway.

Denmark was poorly prepared for the war, and Norway was reluctant to attack Sweden, which left the Swedes in a good position.

The Dano-Swedish War (1657–1658), a part of the Second Northern War, was one of the most devastating wars for the Dano-Norwegian kingdom. After a huge loss in the war, Denmark–Norway was forced in the Treaty of Roskilde to give Sweden nearly half its territory. This included Norwegian province of Trøndelag and Båhuslen, all remaining Danish provinces on the Swedish mainland, and the island of Bornholm.

However, two years later, in 1660, there was a follow-up treaty, the Treaty of Copenhagen, which gave Trøndelag and Bornholm back to Denmark–Norway.

In the aftermath of Sweden's final secession from the Kalmar Union in 1521, civil war and Protestant Reformation followed in Denmark and Norway. When things had settled down, the Rigsraad (High Council) of Denmark became weakened, and was abolished in 1660[6] when Denmark–Norway became an absolutist state and Denmark a hereditary monarchy, as Norway had been since the Middle Ages. These changes were confirmed in the Lex Regia signed on 14 November 1665, stipulating that all power lay in the hands of the king, who was only responsible towards God.[7] The Norwegian Riksråd was assembled for the last time in 1537. Norway kept its separate laws and some institutions, such as a royal chancellor, and separate coinage and army. Norway also had its own royal standard flag until 1748, after that the Dannebrog became the only official merchant flag in the union.

Denmark had lost its provinces in Scania after the Treaty of Roskilde and was always eager to retrieve them, but as Sweden had grown into a great power it would not be an easy task. However, Christian V saw an opportunity when Sweden got involved in the Franco-Dutch War, and after some hesitation Denmark invaded Sweden in 1675.

Although the Danish assault began as a great success, the Swedes led by 19-year-old Charles XI counter-attacked and took back the land that was being occupied. The war was concluded with the French dictating peace, with no permanent gains or losses to either of the countries.

Battle between the frigate HMS Tartar and Norwegian gunboats near Bergen in 1808.

During the French Revolutionary Wars Denmark–Norway at first tried to stay neutral, so it could continue its trade with both France and the United Kingdom, but when it entered the League of Armed Neutrality, the British considered it a hostile action, and attacked Copenhagen in 1801 and again in 1807. In the 1807 attack on Copenhagen the British army confiscated the entire Dano-Norwegian navy on the grounds that Denmark–Norway was about to launch an attack on Britain. The Dano-Norwegian navy had been the only navy left in Europe able to challenge the British navy after the destruction of the Spanish–French navy in the Battle of Trafalgar. The Dano-Norwegian navy was however not prepared for any military operation and the British soldiers found the Dano-Norwegian navy still in dock after the winter season. The Dano-Norwegians were more concerned about preserving their continued neutrality and the entire Dano-Norwegian army was therefore gathered at Danevirke in the event of a French attack, leaving Copenhagen vulnerable to a British attack. The British attack on Danish neutrality effectively forced the Dano-Norwegians into an alliance with Napoleon, and Denmark–Norway allied itself with France.

Denmark–Norway was defeated and had to cede the territory of mainland Norway to the King of Sweden at the Treaty of Kiel. Norway's overseas possessions were kept by Denmark. But the Norwegians objected to the terms of this treaty, and a constitutional assembly declared Norwegian independence on 17 May 1814 and elected the Crown Prince Christian Frederik as king of independent Norway. Following a Swedish invasion, Norway was forced to accept a personal unionbetween Sweden and Norway, but retained its liberal constitution and separate institutions, except for the foreign service. The union was dissolved in 1905.

Denmark–Norway was amongst the countries to follow Martin Luther after the Protestant Reformation, thus the official religion was established as Lutheran Protestantism throughout the entire life span of the kingdom.

There was however one other religious "reformation" in the kingdom during the rule of Christian VI, a follower of Pietism. The period from 1735 until his death in 1746 has been nicknamed "the State Pietism", as new laws and regulations were established in favor of Pietism. Though Pietism did not last for a substantial time, numerous new small pietistic resurrections occurred over the next 200 years. In the end, Pietism was never firmly established as a lasting religious grouping.