In the 14th century Dunnottar was granted to William de Moravia, 5th Earl of Sutherland (d. 1370), and in 1346 a licence to crenellate was issued by David II. Around 1359 William Keith, Marischal of Scotland, married Margaret Fraser, niece of Robert the Bruce, and was granted the barony of Dunnottar at this time. Keith then gave the lands of Dunnottar to his daughter Christian and son-in-law William Lindsay of Byres, but in 1392 an excambion (exchange) was agreed whereby Keith regained Dunnottar and Lindsay took lands in Fife. William Keith completed construction of the tower house at Dunnottar, but was excommunicated for building on the consecrated ground associated with the parish church. Keith had provided a new parish church closer to Stonehaven, but was forced to write to the Pope, Benedict XIII, who issued a bull in 1395 lifting the excommunication. William Keith's descendants were made Earls Marischal in the mid 15th century, and they held Dunottar until the 18th century.