The medieval period marks the earliest recorded history in the area. Arbroath Abbey was founded by William the Lion and dedicated in 1178 and the earldom of Dundee granted to David, Earl of Huntingdon around 1182 (Dundee later gained Royal Burgh status in 1292 on the coronation of David's heir, John Balliol). Closer to Carnoustie, a number of medieval mottes can be found, including at Old Downie, where the thanage can be traced to Duncan of Downie in 1254, and at Grange of Barry, as well as the ruins of Panmure Castle where, it is said, William the Lion signed the Panmure charter granting the lands of Panmure to Philip de Valognes in 1172. The original castle was destroyed at some point in the Second War of Independence, possibly in 1336.