Complex sentence: The attack was ostensibly to support Magnus against Erik, but in June 1359 Erik died, which meant that the balance of power changed and all agreements between Magnus and Valdemar were terminated, including the marriage contract between Margaret and Haakon.
Split into simpler sentences: The attack was ostensibly to support Magnus against Erik, but in June 1359, Erik died. As a result, the balance of power changed and all agreements between Magnus and Valdemar were terminated, including the marriage contract between Margaret and Haakon.