By the ninth century the many kingdoms of the early Anglo-Saxon period had been consolidated into four: Wessex, Mercia, Northumbria and East Anglia. In the eighth century, Mercia had been the most powerful kingdom in southern England, but in the early ninth, Wessex became dominant under Æthelstan's great-great-grandfather, Egbert. In the middle of the century, England came under increasing attack from Viking raids, culminating in invasion by the Great Heathen Army in 865. By 878, the Vikings had overrun East Anglia, Northumbria, and Mercia, and nearly conquered Wessex. The West Saxons fought back under Alfred the Great, and achieved a decisive victory at the Battle of Edington. Alfred and the Viking leader Guthrum agreed on a division that gave Alfred western Mercia, while eastern Mercia was incorporated into Viking East Anglia. In the 890s, renewed Viking attacks were successfully fought off by Alfred, assisted by his son (and Æthelstan's father) Edward and Æthelred, Lord of the Mercians. Æthelred ruled English Mercia under Alfred and was married to his daughter Æthelflæd. Alfred died in 899 and was succeeded by Edward. Æthelwold, the son of Æthelred, King Alfred's older brother and predecessor as king, made a bid for power, but was killed at the Battle of the Holme in 902.
Little is known of warfare between the English and the Danes over the next few years, but in 909, Edward sent a West Saxon and Mercian army to ravage Northumbria. The following year the Northumbrian Danes attacked Mercia, but suffered a decisive defeat at the Battle of Tettenhall. Æthelred died in 911 and was succeeded as ruler of Mercia by his widow Æthelflæd. Over the next decade Edward and Æthelflæd conquered Viking Mercia and East Anglia. Æthelflæd died in 918 and was briefly succeeded by her daughter Ælfwynn, but in the same year Edward deposed her and took direct control of Mercia.
When Edward died in 924, he controlled all of England south of the Humber. The Viking king Sihtric ruled the Kingdom of York in southern Northumbria, but Ealdred maintained Anglo-Saxon rule in at least part of the former kingdom of Bernicia from his base in Bamburgh in northern Northumbria. Constantine II ruled Scotland, apart from the southwest, which was the British Kingdom of Strathclyde. Wales was divided into a number of small kingdoms, including Deheubarth in the southwest, Gwent in the southeast, Brycheiniog immediately north of Gwent, and Gwynedd in the north.