A weak child, Magnus I was named after Charlemagne and would prove to be a formidable opponent to the foreign states who virtually controlled Hordaland. After his father, Olaf I Haraldsson, was dethroned by Cnut II of Denmark in 1028 the Fairhair family moved to the Rus' where the young Magnus was brought up in the Novgorodian court of Yaroslav the Wise.
Following Cnut's death in 1032 the Earl of Lade, Sveinn II, clung on as Denmark's regent in Hordaland but was increasingly embattled. Olaf I had died in 1030 and so Magnus and his family began a campaign to seize the throne back. With assistance from familial connections in Sveinn II was ousted in 1034 and Magnus proclaimed as king. His position was not entirely secure and so sought to drive the Danes out of Viken as well. Using considerable local disenchantment he successfully conquered Viken in 1035 ousting Sveinn I Knutsson.
Sveinn Knutsson would die soon afterwards leaving his inheritance to his much more able half-brother Harthacnut. Magnus and Harthacnut were soon clashing repeatedly with Magnus gaining the upper hand. By 1039 defeats had forced Harthacnut into recognising Magnus as his heir in Denmark. When he did indeed die in 1042 Magnus was duly crowned as King. Harthacnut's cousin Sweyn Estridsson would move from service (as Yarl of Jutland) to open rebellion in time but for much of his reign in Denmark his throne was secure. He destroyed the Jomsborg Vikings as a military force and campaigned effectively against the Wends.
Magnus made no secret of the idea of resurrecting Cnut's great North Sea Empire and he may have planned a full invasion of Anglia much as Harthacnut did. Anglia was much troubled by raiding during this period but no full-scale operation was ever organised.
In 1046 Magnus's uncle Harald IV Hardrada returned from Byzantine and Kievan Rus' service and successfully challenged Magnus for the throne of Hordaland. Meanwhile Sweyn Estridsson had rebelled and seized Scania. Squeezed between Harald and the increasingly rebellious Danes, Magnus released Hordaland to Harald and designated him his heir in the north. Sweyn may have been designated heir of Denmark at the same time. When he died the following year his realm was split and the new kings succeeded without much trouble. However they were soon at loggerheads over who exactly should rule Viken.
Some Danish historians have tended to regard his rule as a 'blip' in the general shift of power from Bergen to Odense. However the future Danish domination of Scandinavia was by no means certain. Harald IV Hardrada was a supremely confident commander whose career would only be cut short by over-reaching and attempting to conquer Anglia. Meanwhile Viken, centred on Oslo, would not remain attached to Denmark for long and would in time rival and briefly outstrip its southern neighbour.