Gruffydd was the son of Llywelyn ap Seisyll, who had been able to rule both Gwynedd and Powys, and Angharad ferch Maredudd. On Llywelyn's death in 1023, a member of the Aberffraw dynasty, Iago ab Idwal ap Meurig, became ruler of Gwynedd and began his rise to power in Powys.
In 1039, King Iago of Gwynedd was killed and his son Cynan, who may have been as young as four, was forced into exile in Dublin. Gruffydd, who had already recovered Powys, expanded into the vacuum. Soon after gaining power, he surprised a Mercian army at Rhyd y Groes near Welshpool and totally defeated it, killing Edwin, brother of the Leofric, Earl of Mercia. He then attacked Dyfed, which his father had ruled but was now under Hywel ab Edwin. Gruffydd defeated Hywel in the Battle of Pencader and carried off Hywel's wife. Gruffydd seems to have been able to drive Hywel out of the south, for in 1044 Hywel is recorded returning to the mouth of the River Tywi with a Danish fleet to try to reclaim his kingdom. Gruffydd, however, defeated and killed him in a closely fought engagement. Gruffydd ap Rhydderch of Gwent was able to expel Gruffydd ap Llywelyn from Deheubarth in 1047 and became king of Deheubarth himself after the nobles of Ystrad Tywi had attacked and killed 140 of Gruffydd ap Llywelyn's household guard. He was able to resist several attacks by Gruffydd ap Llywelyn in the following years. Gruffydd ap Llywelyn was active on the Welsh border in 1052, when he attacked Herefordshire and defeated a mixed force of Normans and English in the Battle of Leominster.
In 1055 Gruffydd ap Llywelyn killed his rival Gruffydd ap Rhydderch in battle and recaptured Deheubarth. Gruffydd allied himself with Ælfgar, son of Leofric, Earl of Mercia, who had been deprived of his earldom of East Anglia by Harold Godwinson and his brothers. They marched on Hereford and were opposed by a force led by the Earl of Hereford, Ralph the Timid. This force was mounted and armed in the Norman fashion, but on 24 October Gruffydd defeated it. He then sacked the city and destroyed its motte-and-bailey castle. Earl Harold was given the task of counter-attacking, and seems to have built a fortification at Longtown in Herefordshire before refortifying Hereford. Shortly afterwards Ælfgar was restored to his earldom and a peace treaty concluded.Around this time Gruffydd was also able to seize Morgannwg and Gwent, along with extensive territories along the border with England. In 1056, he won another victory over an English army near Glasbury. Now recognized as King of Wales, he claimed sovereignty over the whole of the country – a claim which was recognised by the English. Historian John Davies stated that Gruffydd was "the only Welsh king ever to rule over the entire territory of Wales... Thus, from about 1057 until his death in 1063, the whole of Wales recognised the kingship of Gruffudd ap Llywelyn. For about seven brief years, Wales was one, under one ruler, a feat with neither precedent nor successor." During this time, between 1053 and 1063, Wales lacked any internal strife and was at peace.
Death and aftermath
Gruffydd reached an agreement with Edward the Confessor, but the death of his ally Ælfgar in 1062 left him more vulnerable. In late 1062 Harold Godwinson obtained the king's approval for a surprise attack on Gruffydd's court at Rhuddlan. Gruffydd was nearly captured, but was warned in time to escape out to sea in one of his ships, though his other ships were destroyed. In the spring of 1063 Harold's brother Tostig led an army into north Wales while Harold led the fleet first to south Wales and then north to meet with his brother's army. Gruffydd was forced to take refuge in Snowdonia where he met his death. Gruffydd's head and the figurehead of his ship were sent to Harold. The Ulster Chronicle states that he was killed by Cynan in 1064, whose father Iago had been put to death by Gruffydd in 1039. Gruffydd had probably made enemies in the course of uniting Wales under his rule. According to Walter Map, Gruffydd said of this: Following Gruffydd's death, Harold married his widow Ealdgyth, though she was to be widowed again three years later. Gruffydd's realm was divided again into the traditional kingdoms. Bleddyn ap Cynfyn and his brother Rhiwallon came to an agreement with Harold and were given the rule of Gwynedd and Powys. Thus when Harold was defeated and killed at the Battle of Hastings in 1066, the Normans reaching the borders of Wales were confronted by the traditional kingdoms rather than a single king. Gruffydd left two sons who in 1069 challenged Bleddyn and Rhiwallon at the battle of Mechain in an attempt to win back part of their father's kingdom. However they were defeated, one being killed and the other dying of exposure after the battle.