Powys as the easternmost of the major kingdoms of Wales came under the most pressure from the English. This kingdom originally extended east into areas now in England, and its ancient capital, Pengwern, has been variously identified as modern Shrewsbury or a site north of Baschurch. These areas were lost to the kingdom of Mercia. The construction of the earthwork known as Offa's Dyke (usually attributed to Offa, King of Mercia in the 8th century) may have marked an agreed border.
For a single man to rule the whole country during this period was rare. This is often ascribed to the inheritance system practised in Wales. All sons received an equal share of their father's property (including illegitimate sons), resulting in the division of territories. However, the Welsh laws prescribe this system of division for land in general, not for kingdoms, where there is provision for an edling (or heir) to the kingdom to be chosen, usually by the king. Any son, legitimate or illegitimate, could be chosen as edling and there were frequently disappointed candidates prepared to challenge the chosen heir.
The first to rule a considerable part of Wales was Rhodri Mawr (Rhodri The Great), originally king of Gwynedd during the 9th century, who was able to extend his rule to Powys and Ceredigion. On his death his realms were divided between his sons. Rhodri's grandson, Hywel Dda (Hywel the Good), formed the kingdom of Deheubarth by joining smaller kingdoms in the southwest and had extended his rule to most of Wales by 942. He is traditionally associated with the codification of Welsh law at a council which he called at Whitland, the laws from then on usually being called the "Laws of Hywel". Hywel followed a policy of peace with the English. On his death in 950 his sons were able to keep control of Deheubarth but lost Gwynedd to the traditional dynasty of this kingdom.
Wales was now coming under increasing attack by Viking raiders, particularly Danish raids in the period between 950 and 1000. Godfrey Haroldson is said to have carried off two thousand captives from Anglesey on 987, and the king of Gwynedd, Maredudd ab Owain is reported to have redeemed many of his subjects from slavery by paying the Danes a large ransom.
Gruffydd ap Llywelyn was the next ruler to be able to unite most of the Welsh kingdoms under his rule. Originally king of Gwynedd, by 1055 he was ruler of almost all of Wales and had annexed parts of England around the border. However, he was defeated by Harold Godwinson in 1063 and killed by his own men. His territories were again divided into the traditional kingdoms.