In 1046, Harald joined forces with Magnus's rival in Denmark the pretender Sweyn II of Denmark, and started raiding the Danish coast. Magnus, unwilling to fight his uncle, agreed to share the kingship with Harald, since Harald in turn would share his wealth with him. The co-rule ended abruptly the next year as Magnus died, so Harald became the sole ruler of Norway. 