During the 9th century, Norway was divided between several local kings controlling their own fiefdoms. By the end of the century, King Harald Fairhair (Old Norse: Haraldr Hárfagri, Harald Hårfagre in modern Norwegian) managed, mainly due to the military superiority gained by his alliance with Sigurd Ladejarl of Nidaros, to subjugate these mini–kingdoms, and he created the first unified Norwegian state.
This alliance came apart after Harald's death. The jarls of Lade and various descendants of Harald Fairhair would spend the next century interlocked in feuds over power. As well as power politics, religion also played a part in these conflicts, as two of the descendants of Harald Fairhair, Hakon the Good and Olaf Tryggvason attempted to convert the then heathen Norwegians to Christianity. In the year 1000, Svein (Old Norse: Sveinn) and Erik (Old Norse: Eiríkr) of Lade took control over Norway, being supported by the Danish King Svein. In 1015, Olaf Haraldsson, representing the descendants of Harald Fairhair, returned from one of his Viking trips and was immediately elected as King of Norway. In June 1016, he won the Battle at Nesjar against the Jarls of Lade.
Olaf Haraldsson's success in becoming King of Norway was helped by the Danes being kept occupied with the ongoing fighting in England. In the year 1028, the Danish King Cnut the Great made an alliance with the Lades, and Olaf had to go into exile in Novgorod (Old Norse: Garðaríki). In the year of 1029 the last Lade, Hakon Jarl, drowned and Olaf returned to Norway with his army to regain his throne and the Kingdom of Norway.The year after the battle his grave and coffin were opened and according to Snorri Sturluson the body was incorrupt and the hair and nails had grown since he was buried. The coffin was then moved to St. Klement's Church in Trondheim. Olav came to be venerated as a saint and given the name Saint Olaf (Norwegian: Olav den Hellige). Stiklestad Church (Stiklestad kyrkje) was erected on top of the stone against which he died. The stone is supposedly still inside the altar of the church.
One hundred years later, Nidaros Cathedral was built in Trondheim on the site of his original burial place. Olaf's body was moved to this church and enshrined in a silver reliquary behind the high altar. This reliquary took the form of a miniature church, common to medieval reliquaries containing the entire body of a saint, but was unique in that it is said to have had dragon heads at the apex of the gables similar to those still seen on Norwegian stave churches. In the 16th century, during the Protestant Reformation period, Olaf's body was removed from this reliquary, which was melted down for coinage by order of the Dano-Norwegian king. His remains were reburied somewhere in Nidaros Cathedral—exactly where is still today an unsolved mystery. Queen Josephine of Leuchtenberg of Norway and Sweden, the consort of Oscar I, asked for the one known remaining relic of St. Olaf, an ulna or radius in a medieval reliquary in the Danish National Museum, from King Frederick VII of Denmark, which he gave to her and which she in turn gave to St. Olaf's Cathedral (Sankt Olav domkirke) in Oslo in August 1862.