In 1363, former members of the Swedish Council of the Realm, led by Bo Jonsson Grip, arrived at the court in the
Duchy of Mecklenburg-Schwerin. The Swedish noblemen promptly persuaded Duke
Albert II of Mecklenburg, who had gained influence in the affairs of Sweden by marrying Magnus' sister
Euphemia, to intervene against Magnus and Haakon in Sweden and depose them both in favour of his and Euphemia's son
Albert. In 1364, Duke Albert enlisted military support from several powerful
North German noblemen and proceeded to swiftly invade and conquer Sweden and subsequently installed his son as the new king. In November 1365, the younger Albert was formally hailed as Sweden's new king, though he had already been crowned on 18 February 1364. After an invasion, a temporary truce was established between the two warring parties, and though Haakon and Magnus had lost control over much of Sweden, they still maintained control over the important provinces of
Västergötland,
Dalsland and
Värmland. In early 1365, Haakon and Magnus assembled a large army in Västergötland, consisting mainly of Norwegians, but also a large number of Swedes from the said province, and marched on the German-held city of
Stockholm. On 27 February, Haakon issued a proclamation against Albert of Mecklenburg and his supporters, encouraging the local populace to stir up in rebellion against the German usurper. The Norwegian army entered
Uppland through
Västerås and clashed against the Swedish-German army in the disastrous
Battle of Gataskogen where Haakon and Magnus suffered a devastating defeat and Magnus was captured and taken prisoner by the Germans; which he would remain for six years. The chief foreign policy of Haakon was now to retrieve Sweden from the Germans and his father from captivity. He was still in possession of West Sweden and found that he could rely on the support from several noblemen who were displeased with the Germans. The war between Norway and Sweden continued, and Haakon soon found himself in need of allies. He entered into an alliance with King Valdemar, the father of his wife, which was something that later would dramatically concentrate the Norwegian foreign policy to the east, rather than to the traditional west. After a turbulent conflict and war against the North German cities and the
Hanseatic League, Haakon was again free to turn his attention to Sweden, and launched a successful campaign against the Germans in Sweden. The military campaign ended in the
Siege of Stockholm in 1371, where it looked like Haakon could decisively defeat the Germans and acquire revenge for his defeat at the Battle of Gataskogen; but Albert and his German supporters managed to withstand the siege and Haakon was forced to sign a peace treaty. The treaty was signed on 14 August 1371, and Haakon would have to be content with having his father released from captivity against a large ransom. When released, Magnus resumed ruling his remaining domains in Norway and Sweden until his death in 1374 only three years later. == Foreign policies in the east ==