From the year 875, Guthrum, ruler of the Danelaw, made several attacks on Wessex, in his last attack he almost succeeded in capturing the Saxon King Alfred the Great in his winter fortress at Chippenham.
By 878, despite their defeat at the Battle of Ashdown, the Vikings controlled the east and north east of England. After his defeat at Chippenham on Twelfth Night (6th January 878), King Alfred had taken refuge for the winter in the Somerset marsh of Athelney, where he spent four months in hiding contemplating how to defeat the Vikings and famously burnt the cakes.
In the Spring of 878, Alfred emerged from his hiding place, determined to defeat the Vikings, the Anglo Saxon Chronicle records -
'In the seventh week after Easter he rode to Egbert's Stone east of Selwood and there came to meet him all the people of Somerset and Wiltshire and of that part of Hampshire which was on this side of the sea, and they rejoiced to see him.'
The call to war was answered by some two thousand five hundred men and Alfred advanced to meet the enemy. The Saxon army spent the night before the battle at Iley Oak, just to the south of Warminster, before moving out at dawn to meet Guthrum, who was occupying high ground at Edington, then known as Ethandun, near Chippenham in Wiltshire.
The Saxon fyrd lined up in shield wall formation. In a fiercely fought battle which lasted throughout the day, the Saxon forces wore down the Danes. Alfred pursued them back to Chippenham, trapping them in his own fortress there. Asser's Life of King Alfred relates -
"Fighting ferociously, forming a dense shield-wall against the whole army of the Pagans, and striving long and bravely...at last he gained the victory. He overthrew the Pagans with great slaughter, and smiting the fugitives, he pursued them as far as the fortress'
After fourteen days the Vikings sued for peace. Alfred realised that he could not realistically hope to drive the Vikings out of the rest of England. The best he could hope for was to consolidate his current possessions.
By the terms of the peace agreement, known as the Peace of Wedmore, Guthrum agreed to withdraw to territory already under Danish control, that is, behind the Roman Watling Street. Guthrum accepted Christianity, and was baptized, taking the name of Aethelstan, with Alfred standing as sponsor. To render thanks for his victory, Alfred founded Athelney Abbey on the island in 888. The Abbey survived until the Dissolution of the Monasteries under King Henry VIII in 1539.