During the 9th century, Norway was divided between several local kings controlling their own fiefdoms. By the end of the century, King Harald Fairhair  managed, mainly due to the military superiority gained by his alliance with Sigurd Ladejarl of Nidaros, to subjugate these mini-kingdoms, and he created a 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  and Erik  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. Olav 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 Kievan Rus . 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.. Which came first, Sveina ane Erik of Lade taking control of norway, or Olaf Haraldsson being elected King of Norway?