After the defeat of Olaf II at the Battle of Svolder in 1000, Norway fell under the control of the Danish king, Sweyn Forkbeard, and later his son, Cnut the Great. The kingdom was divided, with parts of it ruled by Swedish and Danish kings, breaking the fragile unity that Olaf had sought to establish. Olaf, who had fled into exile, would return in 1015, reclaiming the throne and pushing for Christianization, but his reign was cut short in 1030 when he was killed at the Battle of Stiklestad. His death, however, did not mark the end of his legacy.
In the years following Olaf's death, his son Magnus, born in 1024, was growing up in exile in Novgorod under the protection of Prince Yaroslav the Wise. Meanwhile, Norway remained under the control of Cnut's sons. By 1035, Magnus was invited back to Norway by discontented nobles, and he ascended to the throne as Magnus I "the Good." His return signaled a pivotal moment in Norway’s history. As the son of the revered Olaf, later canonized as Saint Olaf, Magnus' reign was seen as a restoration of legitimate Norwegian kingship.
Magnus worked to consolidate the kingdom, gradually reclaiming control over areas that had fallen under Danish or Swedish influence. He struck a peace with Denmark, eventually even becoming its king in 1042, further stabilizing the political landscape in Scandinavia. His reign helped to reinforce the idea of a unified and independent Norway, setting the stage for future kings to maintain the kingdom's integrity.
Though Magnus' rule would be relatively short—he died in 1047—it marked a crucial step in the consolidation of the Norwegian kingdom. His efforts helped restore the central authority that had been lost after his father's defeat, creating a more unified Norway that would endure under subsequent rulers.