Edinburgh Castle () is a historic castle in Edinburgh, Scotland. It stands on Castle Rock, which has been occupied by humans since at least the Iron Age. There has been a royal castle on the rock since the reign of Malcolm III in the 11th century, and the castle continued to be a royal residence until 1633. From the 15th century, the castle's residential role declined, and by the 17th century it was principally used as a military garrison. Its importance as a part of Scotland's national heritage was recognised increasingly from the early 19th century onwards, and various restoration programmes have been carried out since the middle of the 19th century.

Edinburgh Castle has played a prominent role in Scottish history, and has served variously as a royal residence, an arsenal, a treasury, a national archive, a mint, a prison, a military fortress, and the home of the Honours of Scotland – the Scottish regalia. As one of the most important strongholds in the Kingdom of Scotland, the castle was involved in many historical conflicts from the Wars of Scottish Independence in the 14th century to the Jacobite rising of 1745. Research undertaken in 2014 identified 26 sieges in its 1,100-year history, giving it a claim to having been "the most besieged place in Great Britain and one of the most attacked in the world".Caldwell, pp. 20–24. Few of the present buildings pre-date the Lang Siege of 1573, when the medieval defences were largely destroyed by artillery bombardment. The most notable exceptions are St Margaret's Chapel from the early 12th century, which is regarded as the oldest building in Edinburgh, the Royal Palace, and the early 16th-century Great Hall. The castle is the site of the Scottish National War Memorial and the National War Museum. The British Army is still responsible for some parts of the castle, although its presence is now largely ceremonial and administrative. The castle is the regimental headquarters of the Royal Regiment of Scotland and the Royal Scots Dragoon Guards and houses their regimental museums, along with that of the Royal Scots.

The castle, in the care of Historic Environment Scotland, is Scotland's second most visited tourist attraction, with 2,044,963 visitors in 2025 and over 70 percent of leisure visitors to Edinburgh visiting the castle. As the backdrop to the Royal Edinburgh Military Tattoo during the annual Edinburgh Festival, the castle has become a recognisable symbol of Edinburgh in particular and of Scotland as a whole.

History Pre-history of the Castle Rock Geology

The castle stands upon the plug of an extinct volcano, which is estimated to have risen about 350 million years ago during the lower Carboniferous period. The Castle Rock is the remains of a volcanic pipe, which cut through the surrounding sedimentary rock before cooling to form very hard dolerite, a type of basalt. Subsequent glacial erosion was resisted by the dolerite, which protected the softer rock to the east, leaving a crag and tail formation.McAdam, p. 16.

The summit of the Castle Rock is above sea level, with rocky cliffs to the south, west, and north, rising to a height of above the surrounding landscape.MacIvor (1993), p. 16. This means that the only readily accessible route to the castle lies to the east, where the ridge slopes more gently. The defensive advantage of such a site is self-evident, but the geology of the rock also presents difficulties, since basalt is extremely impermeable. Providing water to the Upper Ward of the castle was problematic, and despite the sinking of a deep well, the water supply often ran out during drought or siege,Dunbar, p. 192. including during the Lang Siege in 1573.

Earliest habitation

An archaeological investigation has yet to establish when the Castle Rock was first used for human habitation. There is no record of any Roman interest in the location during General Agricola's invasion of northern Britain near the end of the 1st century AD. Ptolemy's map of the 2nd century ADHarris, p. 11. shows a settlement in the territory of the Votadini named "Alauna", meaning "rock place", making this possibly the earliest known name for the Castle Rock.Moffat, pp. 268–270. This could, however, refer to another of the tribe's hill forts in the area. The Orygynale Cronykil of Andrew of Wyntoun (c. 1350 – c. 1423), an early source for Scottish history, names "Ebrawce" (Ebraucus), a legendary King of the Britons, as having "byggyd [built] Edynburgh".Andrew of Wyntoun, Orygynale Cronykil of Scotland, quoted in Masson, p. 1. According to the earlier chronicler, Geoffrey of Monmouth (c. 1100 – c. 1155), Ebraucus had fifty children by his twenty wives, and was the founder of "Kaerebrauc" (York), "Alclud" (Dumbarton) and the "Maidens' Castle".Geoffrey of Monmouth, pp. 78–79. The 16th-century English writer John Stow (c. 1525 – 1605), credited Ebraucus with building "the Castell of Maidens called Edenbrough" in 989 BC.Stow, John, Generale Chronicle of England, quoted in Masson, p. 1. The name "Maidens' Castle" ( or ) occurs frequently up until the 16th century.Potter, p. 12. It appears in charters of David I (r. 1124–1153) and his successors in the Kingdom of Scotland,Wilson (1887), p. 298. although the reason for it is not known. William Camden's survey of Britain, Britannia (1607), records that "the Britans called [it] Castle Myned Agned [winged rock], the Scots, the Maidens Castle and the Virgins Castle, of certaine young maidens of the Picts roiall bloud who were kept there in old time". According to the 17th-century antiquarian Father Richard Hay, the "maidens" were a group of nuns, who were ejected from the castle and replaced by canons, considered "fitter to live among soldiers".Halkerston, pp. 8–9: Gillies, p. 3. However, this story was considered "apocryphal" by the 19th-century antiquarian Daniel Wilson and has been ignored by historians since.Wilson claimed that Father Hay had "no better authority for this nunnery than the misleading name castellum Puellarum". Wilson (1891), vol. 1, p. 4, note 4. The name may have been derived from a "Cult of the Nine Maidens" type of legend. Arthurian legends suggest that the site once held a shrine to Morgain la Fee, one of nine sisters.McKean (1991), p. 1. Later, St Monenna, said to be one of nine companions, reputedly invested a church at Edinburgh, as well as at Dumbarton and other places.Grant (c. 1890), p. 15: McHardy, pp. 13–20. Similar names are shared by many other Iron Age hillforts and may have simply described a castle that had never been taken by forcePotter, p. 141. or derived from an earlier Brittonic name like mag dun.Chalmers, cited in Chambers, pp. 35–36.Macritchie.

An archaeological excavation in the early 1990s uncovered evidence of the site having been settled during the late Bronze Age or early Iron Age, potentially making Castle Rock the longest continuously occupied site in Scotland.The claim is advanced by Driscoll & Yeoman, p. 2, although a similar claim is made for other sites including Dumbarton Rock and Kilmartin Glen. However, the extent of the finds was not particularly significant and insufficient to draw any certain conclusions about the precise nature or scale of this earliest known phase of occupation.Driscoll & Yeoman, p. 220.

The archaeological evidence is more reliable concerning the Iron Age. Traditionally, it had been supposed that the tribes of central Scotland had made little or no use of the Castle Rock. Excavations at nearby Dunsapie Hill, Duddingston, Inveresk and Traprain Law had revealed relatively large settlements and it was supposed that these sites had been chosen in preference to the Castle Rock. However, the excavation in the 1990s pointed to the probable existence of an enclosed hillfort on the rock, although only the fringes of the site were excavated. House fragments revealed were similar to Iron Age dwellings previously found in Northumbria.Driscoll & Yeoman, pp. 222–223.

The 1990s dig revealed clear signs of habitation from the 1st and 2nd centuries AD, consistent with Ptolemy's reference to "Alauna". Signs of occupation included some Roman material, including pottery, bronzes and brooches, implying a possible trading relationship between the Votadini and the Romans beginning with Agricola's northern campaign in AD 82, and continuing through to the establishment of the Antonine Wall around AD 140. The nature of the settlement in this period is inconclusive, but Driscoll and Yeoman suggest it may have been a broch, similar to the one at Edin's Hall near Duns in the Scottish Borders.Driscoll & Yeoman, p. 226.

Early Middle Ages

The castle does not re-appear in contemporary historical records from the time of Ptolemy until around AD 600. Then, in the epic Welsh poem Y Gododdin there is a reference to Din Eidyn, "the stronghold of Eidyn". This has been generally assumed to refer to the Castle Rock.MacQuarrie, pp. 29–30. The poem tells of the Gododdin King Mynyddog Mwynfawr,It has been suggested that this is not a proper name of a ruler at all, but rather adjectives used to refer to the warband as a whole. For further discussion cf. and and his band of warriors, who, after a year of feasting in their fortress, set out to do battle with the Angles at "Catreath" (possibly Catterick) in Yorkshire. Despite performing glorious deeds of valour and bravery, the poem relates that the Gododdin were massacred.MacIvor, p. 23.

The Irish annals record that in 638, after the events related in Y Gododdin, "Etin" was besieged by the Angles under Oswald of Northumbria, and the Gododdin were defeated.MacQuarrie, p. 37. The territory around Edinburgh then became part of the Kingdom of Northumbria, which was itself absorbed by England in the 10th century. Lothian became part of Scotland, during the reign of Indulf (r.954–962).Lynch, p. 46.

The archaeological evidence for the period in question is based entirely on the analysis of middens (domestic refuse heaps), with no evidence of structures. Few conclusions can therefore be derived about the status of the settlement during this period, although the midden deposits show no clear break since Roman times.Driscoll & Yeoman, p. 227.

High Middle Ages

The first documentary reference to a castle at Edinburgh is John of Fordun's account of the death of King Malcolm III (1031–1093). Fordun describes his widow, the future Saint Margaret, as residing at the "Castle of Maidens" when she is brought news of his death in November 1093. Fordun's account goes on to relate how Margaret died of grief within days, and how Malcolm's brother Donald Bane laid siege to the castle. However, Fordun's chronicle was not written until the later 14th century, and the near-contemporary account of the life of St Margaret by Bishop Turgot makes no mention of a castle.Tabraham (1997), p. 13. During the reigns of Malcolm III and his sons, Edinburgh Castle became one of the most significant royal centres in Scotland.MacIvor (1993), p. 28. Malcolm's son King Edgar died here in 1107.MacIvor (1993), p. 30.