Map of England showing the Anglo-Saxon kingdoms and Danish districts – from Cassell's History of England, Vol. I – anonymous author and artists
From around 800, there had been waves of Danish raids on the coastlines of the British Isles. In 865, instead of raiding, the Danes landed a large army in East Anglia, with the intention of conquering the four Anglo-Saxon kingdoms of England. The armies of various Danish leaders had come together to provide one combined force under a leadership that included and Ivar the Boneless, the sons of the legendary Viking leader Ragnar Lodbrok. The combined army was described in the annals as the Great Heathen Army. After making peace with the local East Anglian king in return for horses, the Great Heathen Army moved north. In 867, they captured Northumbria and its capital, York, defeating both the recently deposed King Osberht of Northumbria and the usurper Ælla of Northumbria. The Danes then placed an Englishman, Ecgberht I of Northumbria, on the throne of Northumbria as a puppet ruler.
King Æthelred of Wessex and his brother, Alfred, led their army against the Danes at Nottingham, but the Danes refused to leave their fortifications. King Burgred of Mercia then negotiated peace with Ivar, with the Danes keeping Nottingham in exchange for leaving the rest of Mercia alone.
Under Ivar the Boneless, the Danes continued their invasion in 869 by defeating King Edmund of East Anglia at Hoxne and conquering East Anglia. Once again, the brothers Æthelred and Alfred attempted to stop Ivar by attacking the Danes at Reading. They were repelled with heavy losses. The Danes pursued, and on 7 January 871, Æthelred and Alfred defeated the Danes at the Battle of Ashdown. The Danes retreated to Basing (in Hampshire), where Æthelred attacked and was, in turn, defeated. Ivar was able to follow up this victory with another in March at Meretum (now Marton, Wiltshire).
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 the Mercian leader Burgred died during this campaign. Ivar was succeeded by Guthrum, who finished the campaign against Mercia. In ten years, the Danes had gained control over East Anglia, Northumbria and Mercia, leaving just Wessex resisting.
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 the Battle of Cynuit. The modern location of Cynuit is disputed but suggestions include Countisbury Hill, near Lynmouth, Devon, or Kenwith Castle, Bideford, Devon, or Cannington, near Bridgwater, Somerset. 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.