The Northern Isles, which consist of the two island groups of Shetland and Orkney, have been inhabited since prehistoric times but were formally annexed by the Norwegian king Harald Hårfagre in around 875 after he subdued the Vikings who used the islands as a base from which to raid Norway and Scotland.
The islands remained under Norwegian control for almost 600 years, despite increased Scottish interest from the 13th century onwards. Scottish influence began to grow following the death of Jon Haraldsson, the last of an unbroken line of Norse jarls or earls, in 1231 after which the Jarldom passed to ethnic Scots noblemen with permission of the Norwegian King Håkon Håkonsson.
By the time the Scottish noble Henry Sinclair was appointed to the Jarldom of Orkney in 1379, Norway was in decline as a result of the devastating effects of the Black Death that had struck in 1349. The Kalmar Union of 1397 then joined the kingdoms of Denmark and Norway with Sweden under a single monarch.
By the time Margaret of Denmark, the daughter of King Christian I of Denmark and Norway, was betrothed to James III of Scotland in 1468 the Scandinavian monarchy was in a dire financial situation. Unable to raise the dowry payment of 50,000 Rhenish Florins, Christian pledged the islands as security until he could pay. As it became increasingly clear that the dowry was unlikely to be paid, James declared Orkney and Shetland forfeit and they were formally annexed to Scotland on 20 February 1420 through an act of parliament. Although later Danish monarchs attempted to regain the islands by paying the debt, the Scottish kings resisted their efforts.