On 23 April 871, King Æthelred died and Alfred succeeded him as King of Wessex. His army was weak and he was forced to pay tribute to Ivar in order to make peace with the Danes. During this peace the Danes turned to the north and attacked Mercia, a campaign that lasted until 874. Both the Danish leader Ivar and Mercian leader Burgred died during this campaign. Ivar was succeeded by Guthrum, who finished the campaign against Mercia. In ten years the Danes gained control over East Anglia, Northumbria and Mercia, leaving only Wessex to resist.
Guthrum and the Danes brokered peace with Wessex in 876, when they captured the fortresses of Wareham and Exeter. Alfred laid siege to the Danes, who were forced to surrender after reinforcements were lost in a storm. Two years later, Guthrum again attacked Alfred, surprising him by attacking his forces wintering in Chippenham. King Alfred was saved when the Danish army coming from his rear was destroyed by inferior forces at Countisbury Hill, near Lynmouth Devon. Alfred was forced into hiding for a time, before returning in the spring of 878 to gather an army and attack Guthrum at Edington. The Danes were defeated and retreated to Chippenham, where King Alfred laid siege and soon forced them to surrender. As a term of surrender, King Alfred demanded that Guthrum be baptised a Christian; King Alfred served as his godfather.