It is likely that there has been a chapel within Stirling Castle for as long as there has been a castle here. Indeed, the earliest evidence for a castle was the investiture of a chapel within it by Alexander I in 1110. There are frequent later references to chapels at Stirling Castle, and at times it seems possible that there might have been more than one.
There are also frequent references to a Chapel Royal. Perhaps most famously it was in the Chapel Royal at Stirling Castle that the infant Mary Queen of Scots was crowned on 9 September 1543: and where she controversially celebrated Mass on her return from France in 1561. But, rather confusingly, none of this happened in the Chapel Royal you see at Stirling Castle today.
The first of the currently existing royal buildings surrounding the Inner Close was the King's Old Building, built by James IV in 1496. At the same time he established a Chapel Royal. This was an institution as much as a building, and to house it he renovated an existing chapel, possibly in a building with a footprint overlapping the later Chapel Royal, but further forward, intruding into the Inner Close and partly obscuring the King's Old Building.
James IV probably intended to rebuild the Chapel Royal after the Great Hall was completed in 1504, but the Battle of Flodden intervened in 1513 and he never got round to it. See our Historical Timeline for the wider picture.
By 1583 a report prepared for James VI cataloguing the structural shortcomings of the castle noted many leaking roofs. The biggest problems related to the Chapel Royal. Design flaws in the roof seemed to place it beyond repair and the Chapel's location in any case spoiled the otherwise neat pattern of the Inner Close. The recommendation was to demolish it and rebuild it a little to the north.
Nothing was done at the time, but circumstances changed in 1594. It had become clear that Queen Elizabeth of England was not going to produce an heir and James VI of Scotland was her obvious successor. James' wife, Anne of Denmark, gave birth to their son, Prince Henry, on 19 February 1594. James wanted a venue suitable for the christening of the boy born to inherit the unified crowns of Scotland and England.
The new Chapel Royal was completed in time for the christening of Prince Henry, which took place on 30 August 1594. It is a simple rectangular single storey building on a sloping site that completes the now neat square of the Inner Close. The following century the chapel was heavily decorated by the artist Valentine Jenkins in preparation for the visit of Charles I in 1633.
But while the Union of the Crowns brought about the Chapel Royal's creation it also led to its decline. Stirling Castle's role changed from royal residence to military base in 1685, though this was only formal recognition of what had already happened. By the start of the 1900s the chapel building was used as canteen and training rooms for the garrison, while an inserted upper floor was used for stores.
Restoration began in the 1930s with the removal of the extra floor, but it took until 1996 for the Chapel Royal to be fully restored to the condition you see it in today, complete with the reconstruction of the magnificent decoration put in place for Charles I's visit.