He was the youngest son of King Håkon Håkonsson and his wife Margaret Skuladotter. He was born in Tunsberg and was baptised in May 1238. He spent most of his upbringing in Bergen. In 1257 his older brother Håkon died, leaving Magnus the heir-apparent to the kingdom. His father gave him the title of king the same year. On 11 September 1261, he married the Danish princess Ingeborg, the daughter of the late Danish King Erik Plogpenning, after she was practically abducted by King Håkon's men from the monastery she was living in. The struggle to claim Ingeborg's inheritance from her murdered father later involved Norway in intermittent conflicts with Denmark for decades to come. Magnus and Ingeborg were crowned directly after their marriage, and Magnus was given Ryfylke for his personal upkeep. On 16 December 1263 King Håkon died while fighting the Scottish king over the Hebrides, and Magnus became the ruler of Norway.