i'' The times leading up to Merfyn's reign were unsettled for both Gwynedd and neighbouring
Powys. Both kingdoms were beset by internal dynastic strife, external pressure from
Mercia, and bad luck with nature. In 810, there was a bovine plague that killed many cattle (the primary form of wealth at the time) throughout
Wales. The next year, the ancient wooden
llys at
Deganwy was struck by lightning. A destructive war for control of Gwynedd raged between 812 and 816, while in Powys a son of the king was killed by his brother "through treachery". In 818, there was a notable battle at
Llanfaes on
Anglesey. Although our sources do not identify the combatants, the site had been the llys of King Cynan.
Coenwulf of Mercia took advantage of the situation in 817, occupying
Rhufoniog (see map) and laying waste to the mountains of
Snowdonia. Coastal Wales along the
Dee Estuary must have remained under Mercia's control through 821, as Coenwulf is recorded dying peacefully at
Basingwerk in that year. In 823, Mercia laid waste to Powys and returned to Gwynedd to burn Deganwy to the ground. Gwynedd and Powys then gained a respite when Mercia's attention turned elsewhere and its fortunes waned. King
Beornwulf was killed fighting the
East Anglians in 826, his successor
Ludeca suffered the same fate the following year, and Mercia was conquered and occupied by
Ecgberht of Wessex in 829. Though Mercia managed to throw off Ecgberht's rule in 830, it was thereafter beset by dynastic strife and never regarded its former dominance, either in Wales or eastern
England. == Family background and marriage ==