Though birth years of 1208, 1206, and 1215 have been put forward for Dafydd, it has recently been persuasively argued that he was born shortly after Easter 1212. Born at Castell Hen Blas, Coleshill, Bagillt in Flintshire, he was the only son of Llywelyn the Great by his wife, Joan (daughter of King John of England). His grandfather was facing trouble in England against his Barons when he was born. In his final years, Llywelyn went to great lengths to have Dafydd accepted as his sole heir. By Welsh law, Dafydd's older half-brother Gruffydd had a claim to be Llywelyn's successor. Llywelyn had Dafydd recognised as his named heir by his uncle King Henry III of England in 1220, and also had Dafydd's mother Joan declared legitimate by the Pope to strengthen Dafydd's claim.
There was considerable support for Gruffydd in Gwynedd. Although Dafydd lost one of his most important supporters when his mother died in 1237, he retained the support of Ednyfed Fychan, the Seneschal of Gwynedd who wielded great political influence. Llywelyn suffered a paralytic stroke in 1237, and Dafydd took an increasing role in government. Dafydd ruled Gwynedd following his father's death in 1240.
Although King Henry III of England had accepted his claim to rule Gwynedd, he was not disposed to allow him to retain his father's conquests outside Gwynedd. As the diplomatic situation deteriorated, Dafydd began to explore alliances with others against Henry, and is known to have sent ambassadors to the court of Louis IX of France. In August 1241, however, the King invaded Gwynedd, and after a short campaign, Dafydd was forced to submit. Under the terms of the Treaty of Gwerneigron, he had to give up all his lands outside Gwynedd, and also to hand over to the King his half-brother Gruffydd. whom he had imprisoned. Henry thereby gained what could have been a useful weapon against Dafydd, with the possibility of setting Gruffydd up as a rival to Dafydd in Gwynedd, but in March 1244 Gruffydd fell to his death while trying to escape from the Tower of London by climbing down a knotted sheet.
This freed Dafydd's hands, and he entered into an alliance with other Welsh princes to attack English possessions in Wales. He enjoyed several successes in the north: by March 1245 he had recovered the castle of Mold along with his former possessions in modern-day Flintshire, and it is possible that the castle of Dyserth also fell to his men in the summer. In August 1245 King Henry again invaded Gwynedd, but his army suffered a defeat in a narrow pass by Dafydd's men. Undaunted, Henry proceeded as far as the river Conwy, and began building a new castle at Deganwy.
Dafydd also began diplomacy with Pope Innocent IV, the result of which was a recognition by the Vatican of his right to rule over north Wales. After a flurry of diplomatic activity by Henry, the decision was reversed in 1245. Savage fighting continued at Deganwy until Henry, some of whose supplies had been captured by the Welsh, ran short of provisions. A truce was agreed and Henry's army withdrew in the autumn. The truce remained in effect throughout the winter, but the war was effectively ended by the sudden death of Dafydd in the royal home at Abergwyngregyn, in February 1246. He was buried with his father at the abbey of Aberconwy. The writer of Brut y Tywysogyon described him as tarian Cymru - the shield of Wales. The poet Dafydd Benfras composed an elegy in his honour.
Since Dafydd's marriage to Isabella de Braose, daughter of William de Braose, had failed to produce an heir (though some early modern genealogists record him as having sired sons, including Dafydd) the two elder sons of Gruffydd, Llywelyn ap Gruffudd and Owain ap Gruffydd, divided Gwynedd between them and continued the war with King Henry until April 1247, when Llywelyn and Owain met the King at Woodstock and came to terms with him at the cost of the loss of much territory. The pair would continue to rule over Gwynedd jointly until Llywelyn's victory over Owain at the battle of Bryn Derwin in 1255.