In 877AD Ragnar finally died. There was some dispute between Guthrum and Haldan about who should succeed but Halfdan won that argument. From then on everything seemed to go badly for the Danes. Guthrum took over in the North and Halfdan the south.
The next year, in the seventh week after Easter, around Whit (May 878AD), Elfred gave up his guerrilla war in Somerset and rode to 'Egbert’s Stone' east of Selwood, where he was met by "all the people of Somerset and of Wiltshire and of that part of Hampshire which is on this side of the sea (that is, west of Southampton Water), and they rejoiced to see him". Elfred's emergence from his marshland stronghold was part of a carefully planned offensive that entailed raising the Fyrds of three shires. This meant not only that the king had retained the loyalty of ealdormen, royal reeves and king's thegns (who were charged with levying and leading these forces), but that they had maintained their positions of authority in these localities well enough to answer his summons to war. Elfred's actions also suggest a system of scouts and messengers built up during his four years in Somerset.
Elfred won a decisive victory in the ensuing Battle of Eddington, which may have been fought near Westbury, Wiltshire. He then pursued the Danes to their stronghold at Chippenham and starved them into submission. One of the terms of the surrender was that Halfdan convert to Christianity. Three weeks later the Danish king and 29 of his chief men were baptised at Elfred's court at Aller, near Athelney, with Elfred receiving Halfdan as his spiritual son.
The "unbinding of the chrism" took place with great ceremony eight days later at the royal estate at Wedmore in Somerset, after which Halfdan fulfilled his promise to leave Wessex. Whilst at Wedmore, Elfred and Halfdan divided England between them. The boundary between Elfred's and Halfdan's kingdoms was to run from the Thames, to Luton; from there extend in a straight line to Bedford; and from Bedford follow the Ouse to Watling Street.
By terms of the treaty, both agreed to Lundin regaining its independence (at least for the time being). Both were satisfied with the arrangement, admittedly Elfred more than Halfdan. However they underestimated Guthrum’s reaction and completely forgot about Constantine and Aelle!