This is Craigmillar Castle on the outskirts of Edinburgh. It may seem familiar with any Outlander fans as it was used in season 3 as Ardsmuir prison where Jamies friendship with Lord John Grey began.
One of its claim to fame is that Mary Queen of Scots used the castle as a safe haven in 1566. The castles owner Sir Simon Preston who gave her sanctuary would turn against her only one year later. It is also rumoured that the plot to kill her husband Lord Darnley was hatched here by the Earl of Bothwell.