Lochmaben Castle is a ruined castle in the town of Lochmaben, the feudal Lordship of Annandale, and the united county of Dumfries and Galloway. It was built by Edward I in the 13th and 14th centuries, and later rebuilt during the reign of James IV of Scotland. An earlier motte-and-bailey castle was built south of the current castle in c. 1160 by the Bruce family, Lords of Annandale.
King Edward replaced the castle with a much sturdier structure at the south end of Castle Loch around 1300 and its remains still show the massive strength of its defences. Archibald Douglas, Lord of Galloway, with the assistance of the Earls of March and Douglas, after a siege of nine days, took Lochmaben Castle from the English and "razed it to the ground" on 4 February 1384/5. The castle and barony became a possession of the Earls of March, but when the 10th Earl was forfeited and then reinstated, in 1409, it is noted that it was "with the exception of the castle of Lochmaben and the Lordship of Annandale" which by July 1455 was in the possession of Alexander Stewart, Duke of Albany, etc.,(d.1485). Following his death both the Lordship and the castle were annexed to the Crown by Act of Parliament dated October 1, 1487.
On 16 January 1508/9, at Edinburgh, Sir Robert Lauder of The Bass (d.1517/8), knight, was appointed "Captain and Keeper of the King's castle and fort of Lochmaben, with all pertinentes" and other privileges etc., for three years. In 1605 the Depute Lieutenant of the Borders, Sir William Cranstoun of that Ilk (later 1st Lord Cranstoun), was Keeper of Lochmaben Castle.
Lochmaben Castle remained important and had a turbulent history until some time after the early 17th century by which time it had seen its last siege and was gradually abandoned.