On 24 June 1229, the young king married Eleanor of Portugal, daughter of Afonso II of Portugal, at Ribe. The match had been arranged by Bishop Gunner of Viborg who the couple loved like a father. They had been married for two years when Queen Eleanor died in childbirth on 28 August 1231. The child was short-lived.