Craigmillar Castle is a ruined medieval castle in Edinburgh, Scotland. It is situated 3 miles (4.8 km) south-east of the city centre, on a low hill to the south of the modern suburb of Craigmillar. It was begun in the late 14th century by the Preston family, feudal barons of Craigmillar, and extended through the 15th and 16th centuries. In 1660 the castle was sold to Sir John Gilmour, Lord President of the Court of Session, who made further alterations. The Gilmours left Craigmillar in the 18th century, and the castle fell into ruin. It is now in the care of Historic Scotland.
Craigmillar Castle is best known for its association with Mary, Queen of Scots. Following an illness after the birth of her son, the future James VI, Mary arrived at Craigmillar on 20 November 1566 to convalesce. Before she left on 7 December 1566, a pact known as the "Craigmillar Bond" was made, with or without her knowledge, to dispose of her husband Henry Stuart, Lord Darnley.
Craigmillar is one of the best-preserved medieval castles in Scotland. The central tower house, or keep, is surrounded by a 15th-century courtyard wall with "particularly fine" defensive features. Within this are additional ranges, and the whole is enclosed by an outer courtyard wall containing a chapel and a doocot.