In 1814, the Kingdom of Norway made a brief and ultimately unsuccessful attempt to regain its independence. While Norway had always legally been a separate kingdom, since the 16th century it had shared a monarch with Denmark; Norway was a subordinate partner in the combined state, whose government was based in Copenhagen. Due to its alliance with France during the Napoleonic Wars, Denmark was forced to sign the Treaty of Kiel in January 1814 ceding Norway to Sweden. However, many Norwegians were inspired by the rising tide of nationalism and resented being handed over without their consent to Sweden, a state they viewed as a traditional rival. Under the leadership of Christian Frederick, who was the Danish government's representative in Norway and also the king of Denmark's cousin and heir presumptive, Norway attempted to assert its rights as an independent state. A government was established and a constitution written, under which Christian Frederick was elected king of Norway in May 1814. The fledgeling Norwegian state was unable to gain support or recognition from any foreign powers, and was defeated in a two-week war with Sweden in the summer of 1814. However, the Convention of Moss, signed at the end of the war in August, preserved many of the independence movement's achievements: Norway remained mostly autonomous in a personal union with Sweden, and was permitted to retain its new constitution with only slight modifications. Christian Frederick, forced to abdicate as king of Norway, would become king of Denmark as Christian VIII in 1839. Norway would eventually fully break away from Sweden in 1905. Prior to 1814 – The independence movement Denmark–Norway was involved as a part of the French side in the Napoleonic War through its participation in the Gunboat War. After Denmark-Norway lost its fleet, the shores remained defenceless by sea as the tides turned against France. The Royal Navy had blockaded all Norwegian ports effectively from 1808, thus severing all Dano-Norwegian connections and leaving the nation of Norway to handle diplomacy by itself. Under those conditions, tension grew in Norway, and a fledgling independence movement was formed in 1809, but with roots as far back as at least the 1790s. In the Swedish campaign against Norway in 1808–09, Sweden had been repulsed by the Norwegian army, and this was also a factor which made Norwegians more prone to independence. The years of 1812 and 1813 were known for severe