Dalkeith Castle was located to the north east of Dalkeith, and was originally in the hands of the Clan Graham in the 12th century and given to the Clan Douglas in the early 14th century. James Douglas of Dalkeith became the Earl of Morton in the mid 15th century. The castle was strategically located in an easily defensible position above a bend in the River North Esk.
In 1642, Dalkeith Castle was sold by the Douglas family to Francis Scott, 2nd Earl of Buccleuch. The 2nd Earl of Buccleuch's daughter married the Duke of Monmouth, eldest illegitimate son of King Charles II. They became the Duke and Duchess of Monmouth & Buccleuch. After the Duke of Monmouth had been executed for treason, Anne Scott, 1st Duchess of Buccleuch, his widow, who held the Scottish title in her own right, asked architect James Smith to use William of Orange's Palace of Het Loo in the Netherlands as a model for the new Dalkeith Palace.
Smith and his cousins, Gilbert and James, signed the contract for mason work at Dalkeith Castle in March 1702. Construction of Dalkeith Palace began later that year, Smith deciding to incorporate a portion of the tower house of the old castle into the western side of the new structure. The outline of the old tower walls is still visible in the western facade of the palace today.
The 5th Duke of Buccleuch considered extensive rebuilding in 1831 and William Burn produced unexecuted designs in Jacobean style. More minor alterations were carried out, together with improvements to the surrounding estate including a new house and offices for the Duke's Chamberlain, and the construction, for the 5th Duke, of St Mary's Church as a private chapel by William Burn and David Bryce. The church contains one of only two water-powered organs in Scotland.
References:The Church of St Donatus name refers to Donatus of Zadar, who began construction on this church in the 9th century and ended it on the northeastern part of the Roman forum. It is the largest Pre-Romanesque building in Croatia.
The beginning of the building of the church was placed to the second half of the 8th century, and it is supposed to have been completed in the 9th century. The Zadar bishop and diplomat Donat (8th and 9th centuries) is credited with the building of the church. He led the representations of the Dalmatian cities to Constantinople and Charles the Great, which is why this church bears slight resemblance to Charlemagne's court chapels, especially the one in Aachen, and also to the Basilica of San Vitale in Ravenna. It belongs to the Pre-Romanesque architectural period.
The circular church, formerly domed, is 27 m high and is characterised by simplicity and technical primitivism.