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). A clause in the agreement signed by Llywelyn and King John in August 1211 contains a clause that implies Llywelyn had not sired an heir by his wife Joan at that time; the date of Dafydd's birth is now believed to be between this date and early 1215. In his last 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 consideration as 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 position.
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 and the wielder of 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 the possibility of allying 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 been keeping a prisoner. 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 Gruffydd died trying to escape from the Tower of London by climbing down a knotted sheet, and fell to his death in March 1244.
This freed Dafydd's hands, and he entered into an alliance with other Welsh princes to attack English possessions in Wales. Dafydd enjoyed several successes in the north; by March 1245 Dafydd had recovered the castle of Mold, 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 and built 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 until the withdrawal of Henry's army from Wales in the autumn, but the war was effectively ended by the sudden death of Dafydd in the royal home Garth Celyn Aber Garth Celyn, 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.
Since Dafydd's marriage to Isabella de Braose, daughter of William de Braose, 10th Baron Abergavenny, had failed to produce an heir, the two elder sons of Gruffydd, Llywelyn ap Gruffydd 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.