Within a generation of the construction of Offa's Dyke, the greater part of the country's inhabitants became the subjects of a single ruler.
Rhodri Mawr, king of Gwynedd, had by his death in AD 877 added Powys and Seisyllwg (essentially the later counties of Cardigan and Carmarthen) to his kingdom.
Rhodri's death in 878 at the hands of Anglo-Saxons from Mercia caused the union between the North and Seisyllwg to cease for a time. It was later revived by his grandson, Hywel (c. 880-950), who also ruled over Dyfed and Brycheiniog.
The regions, along with Seisyllwg, were collectively known thereafter as Deheubarth. Like Rhodri, Hywel was given an epithet: he became Hywel Dda (the Good).
Hywel followed a more conciliatory policy than Rhodri Mawr. He attended the English court and recognised the English King as overlord. His reputation, however, was sealed after tradition associated him with the codification of the Welsh laws, also known as the law of Hywel.
The process of unity came to a climax under Hywel's great-great-grandson, Gruffudd ap Llywelyn, who by 1057 had united the whole of Wales under his authority.
Gruffudd ap Llywelyn was more aggressive than his predecessors. As part of his campaign to unite Wales, he seized extensive territories, long lost by the Welsh, to the east of Offa's Dyke.
Harold, Earl of Wessex, invaded Wales in 1063 and Gruffudd was hunted down and killed. Three years later William, Duke of Normandy, seized the throne of England.
Missed an episode? Catch up on the BBC iPlayer.
Phil Carradice blogs about William Haggar - a pioneer of British cinema.