When was Edinburgh Castle built?

Castle Rock, a 130-metre (430-foot) outcrop created by an extinct volcano that was active around 350 million years ago, has been inhabited since the late-Bronze Age, around 800 BCE.TS108585159

The Greek-Egyptian geographer Ptolemy is thought to have recorded a settlement here around 150 CE, but the first reference to a fortification here, known as Din Eidyn, or the Stronghold of Eidyn, comes from a Welsh epic poem circa 600 CE.

Archaeological evidence backs up the idea of habitation but shows no signs of a real castle, per se. The first definitive reference of a castle comes from the reign of King David I, who held assemblies of nobles and clerics here from 1139 onwards.