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 Walls of Constantinople are a series of defensive stone walls that have surrounded and protected the city of Constantinople (today Istanbul) since its founding as the new capital of the Roman Empire by Constantine the Great. With numerous additions and modifications during their history, they were the last great fortification system of antiquity, and one of the most complex and elaborate systems ever built. They were also the largest and strongest fortification in both the ancient and medieval world.
Initially built by Constantine the Great, the walls surrounded the new city on all sides, protecting it against attack from both sea and land. As the city grew, the famous double line of the Theodosian Walls was built in the 5th century. Although the other sections of the walls were less elaborate, they were, when well-manned, almost impregnable for any medieval besieger.