In 877 Rhodri, after many vicissitudes, was slain in battle, and his dominions of Gwynedd (North Wales), Deheubarth (South Wales) and Powys (Mid Wales) were divided amongst his three sons, Anarawd, Cadell and Mervyn.
Consolidation of CambroBritish territory was found impossible; there was no settled capital; and the three princes fixed their courts respectively at Aberffraw in Anglesea, at Dynevor (Dinefawr) near Llandilo in Deheubarth, and at Mathrafal in Powys.
In Howel's code the prince of Gwynedd with his court at Aberffraw is recognized as the leading monarch in Wales; next to him ranks the prince of Deheubarth, and third in estimation is the prince of Powys.
The dissensions of the turbulent princes of Gwynedd, Powys and Deheubarth, and of their no less quarrelsome chieftains, now rent the country, which was continually also a prey to Saxon incursions by land and to Scandinavian attacks by sea.
At the accession of William Rufus the domain of Gwynedd had been reduced to Anglesea and the Snowdonian district, and that of South Wales, or Deheubarth, to the lands contained in the basins of the rivers Towy and Teifi, known as Ystrad Tywi and Ceredigion.
At the castle of Cardigan in 1176, Prince Rhys held a historic bardic entertainment, or eisteddfod, wherein the poets and harpists of Gwynedd and Deheubarth contended in amicable rivalry.
But in 1199 the celebrated Gerald de Barri (Giraldus Cambrensis), archdeacon of Brecon and a member of the famous Norman baronial house of de Barri, and also through his grandmother Nesta a great-grandson of Prince Rhys ap Tudor of Deheubarth, was elected bishop by the chapter of St Davids.
Glamorgan and the county palatine of Pembroke had hitherto been the only portions of the country subject to English shire law, but now Edward parcelled out the ancient territory of the princes of Gwynedd and of Deheubarth into six new counties, with sheriffs, coroners and bailiffs.