In 974, Hywel ab Idwal had managed to expel his uncle, Iago ab Idwal Foel from Gwynedd. At some stage, however, Iago returned. In 978, Hywel, with English assistance, raided the monastery of Clynnog Fawr (on the coast, south of Caernarfon). Presumably, this attack was directed at Iago. The following year, the Welsh annals report that Iago was captured (the C-text of the 'Annales Cambriae' makes it clear that it was by Vikings). Iago is never heard of again. This convenient turn of events allowed Hywel to take over Iago's territories. Iago's son, Custennin, allied himself with Manx Viking Godfrey Haraldson, and, in 980, they attacked Môn (Anglesey) and the Llyn peninsula. (Godfrey was no stranger, having raided Anglesey before, in 972). Custennin was killed in battle against Hywel. Godfrey sailed south, and ravaged Dyfed. Dyfed was the heartland of Deheubarth - ruled by Owain ap Hywel Dda. Since at least 970, Owain's son, Einion, had been leading the kingdom's warband. There is no evidence that Owain had abdicated, so it seems a reasonable supposition that he was in some way incapacitated. In 983, Hywel ab Idwal, in alliance with Ælfhere, ealdorman of Mercia, attacked Deheubarth's north-eastern territories: Brycheiniog and surrounds.
Einion, apparently, managed to drive-off the invaders, inflicting heavy losses on them. The following year Einion was killed, "through treachery by the nobles of Gwent", says the 'Brut y Tywysogion'. Whether the "nobles of Gwent" had been in cahoots with Hywel ab Idwal is a debatable point. They would certainly have been concerned by Deheubarth's eastwards expansion - Gower had probably been, only recently (or possibly was still in the process of being), annexed by Deheubarth. Einion's brother, Maredudd, succeeded him (though Owain was still alive). Just a year later (985), Hywel ab Idwal was killed by the English. There appears to have been a brief dispute, over the succession, between Cadwallon, Hywel's brother, and their cousin, Ionafal ap Meurig. Within the year, Cadwallon had killed Ionafal. In 986, Maredudd marched against Cadwallon. Cadwallon was killed, and Maredudd:
Maredudd now ruled all but south-eastern Wales - as his grandfather, Hywel Dda, had done before him. Maredudd's reign, however, was not comfortable. In 987, Godfrey Haraldson, once more, ravaged Anglesey. Godfrey is reported to have taken two thousand captives. Maredudd was forced back into Ceredigion and Dyfed. The Vikings spent the next year plundering their way around the Welsh coast, from Ceredigion to Morgannwg, and, in 989, Maredudd bought back an unspecified number of captives. In the meantime, in 988, Maredudd's father, Owain, had died. In 991, Maredudd ravaged Maes Hyfaidd (Radnor, Powys). No details are recorded, but the location suggests that the attack may have been directed at the English. The next year (992), Maredudd faced a challenge from his nephew, Edwin ab Einion. Edwin, aided by an English army, raided Dyfed, Ceredigion, Gower and Cydweli. Maredudd must have defeated Edwin - no more is heard of him. Perhaps bolstered by his success, Maredudd hired a Viking army, and launched a raid into Morgannwg. In 993, the 'Gwynedd branch' of the family, in the form of "the sons of Meurig", launched a come-back. The following year, they may even have driven Maredudd out of Gwynedd, having beaten him in battle near Llangwm. (Edwin's brother, Tewdwr ab Einion, was killed in the battle - presumably he was on Maredudd's side). In 999, Maredudd died. At the time of his death, he was king of Deheubarth, but it is difficult to say with any degree of certainty whether or not he still ruled Gwynedd. One of the "sons of Meurig", Idwal, was reported to have been killed in 996. Who did the killing, and under what circumstances, are not mentioned. It could be that Idwal's death was the result of a feud within the 'Gwynedd branch', rather than by continuing conflict with Maredudd. The 'Brut y Tywysogion', in its obit of Maredudd, calls him "the most celebrated king of the Britons", which may be suggestive that he had managed to retain control of Gwynedd. At any rate, following his death, Gwynedd certainly reverted to the 'Gwynedd branch'. Just a year later (i.e. 1000), the Welsh annals report that Gwynedd was being ruled by Cynan ap Hywel. Cynan was killed in 1003. Once more, no details are supplied. Meanwhile, the Viking assault on Wales appears to have been pretty relentless. Anglesey and St.Davids, on the western-most peninsula of Dyfed, continued to be favourite targets.
There must have been some small Viking settlements, particularly at coastal sites, and it is probably from this period that some coastal locations began to adopt the Scandinavian names by which, in modified form, they are still known - for instance Swansea, Milford Haven and Fishguard; the islands Bardsey, Caldey and, perhaps most famously, the traditional island stronghold of Gwynedd, Môn, would become 'Ongul's Isle' i.e. Anglesey. After their record of Of Cynan's killing, in 1003, the Welsh Annals enter a very barren period. The next event of interest is the mention, without any indication of motive, that, in 1012, Eadric 'Streona', ealdorman of Mercia, mounted a raid against St.Davids.
In 1018 Llywelyn ap Seisyll killed Aeddan ab Blegywryd and his four sons. Quite who Aeddan was is open to speculation, but Llywelyn was probably king of Gwynedd - he certainly was four years later. Llywelyn's background is obscure. Medieval genealogists contrived to make his mother (Prawst) the daughter of an otherwise unknown son (Elisedd) of Anarawd ap Rhodri Mawr. It is not unreasonable to assume that both Prawst and Elisedd are inventions. From the 'Brut y Tywysogion', it is known that Llywelyn married Angharad, daughter of Maredudd ab Owain. In 1022, an Irishman called Rhain, claiming to be the son of Maredudd, gained acceptance as king of Deheubarth:
Rhain was defeated, at Abergwili - he fled, never to be seen again. Llywelyn followed up his victory by ravaging Deheubarth ("destroying it as far as Mercia").
In 1023, Llywelyn ap Seisyll died. It would appear that his son was too young to step into his shoes, and control of Gwynedd returned to the dynasty of Merfyn Frych - Iago ab Idwal ap Meurig. In the same year, Rhydderch ab Iestyn seized control of Deheubarth.
Cynan ap Seisyll, Llywelyn's brother, seemingly mounted an unsuccessful campaign to take control of Gwynedd, since his killing is recorded in 1027. Rhydderch ab Iestyn was killed, by the Irish (the annals do not record the circumstances), in 1033. Rule of Deheubarth reverted to the dynasty of Merfyn Frych - Hywel and Maredudd, sons of Edwin ab Einion. Rhydderch's sons, apparently, succeeded him in Morgannwg, and were clearly not content to lose control of Deheubarth without a contest. The following year (1034), Edwin's sons and Rhydderch's sons fought the battle of Irathwy. Presumably Edwin's sons were victorious (the outcome is not recorded), since Hywel was king of Deheubarth until his death, in 1044. Hywel's brother, Maredudd, however was killed just a year after Irathwy, by "the sons of Cynan" - who may (or may not) be the sons of Cynan ap Seisyll.
Possibly, having lost Deheubarth, Rhydderch's sons attempted to expand their territory eastwards, since, also in 1035, one of them, Caradog, was killed by the English. In 1039: