The first building placed at Dinas Brân was not the castle which now stands in ruins on top of the hill but an Iron Age hillfort built around 600 BC. An earthen rampart was constructed probably topped by a wooden palisade and this was further protected by a deep ditch on the shallower southern slope.
The walls of the hillfort encircled a village of roundhouses. Dinas Brân is one of many hillforts in this part of Wales; Moel y Gaer is just a couple of miles to the north-west near the Horseshoe Pass, and another is close by at Y Gardden in Ruabon to the east. There are many others on the Clwydian Hills further to the north and in the Marches to the south. Dinas Brân is in what was once the ancient Kingdom of Powys. The last Prince of Powys Gruffydd Maelor died in 1191 and the kingdom was divided into Powys Fadog in the north and Powys Wenwynwyn in the south. His son, Madog ap Gruffydd Maelor was lord of Powys Fadog and founded the nearby Valle Crucis Abbey. Although no archaeological evidence has been found some records suggest he ruled from Dinas Brân. If a structure did exist it would have been a wooden fortification probably consisting of a wooden palisade surrounding a hall and other buildings.
These early records further say it was destroyed by fire and then the new castle was built on the same site, therefore little prospect for finding any archaeological evidence of the early building remains. An even earlier structure has been suggested, belonging to Elisedd ap Gwylog from the 8th century. It was this Elisedd who is named on the Pillar of Eliseg and is one of the founders of the kingdom of Powys, but again no physical evidence for any structure at Dinas Brân has been found.The castle visible today was probably built by Gruffydd II ap Madog son of Madog ap Gruffydd Maelor sometime in the 1260s. At the time Gruffydd II ap Madog was an ally of Prince Llywelyn ap Gruffudd Prince of Wales, with Powys acting as a buffer state between Llewelyn’s heartland of Gwynedd and England. Dinas Brân was one of several castles being built following the signing of the Treaty of Montgomery which had secured Wales for Llywelyn, free from English interference. Indeed, the castle at Dolforwyn Castle near Newtown ordered to be built by Llywelyn around the same time has some similarities to Dinas Brân and may have been the work of the same master mason.