Gavin Dunbar, his uncle, resigned as Dean of Moray on 5 November 1518 to take up the post of bishop of Aberdeen but managed to secure his former position for his nephew.
By 1518 he was preceptor to king James V and that same year was recommended to Pope Leo X by the Duke of Albany for provision to the Priory of Whithorn.
On 29 February 1528, Dunbar attended the trial and signed the sentence of Patrick Hamilton, who was burned alive for six hours before dying (the faggots were wet), a death which made him one of the Scottish Reformation's most famous martyrs.
George MacDonald Fraser, in his history of the Reivers, The Steel Bonnets, admiringly calls it a "remarkable burst of invective," and says that it places Dunbar "among the great cursers of all time."
Gavin issued the curse in October 1525 during efforts for Anglo-Scottish peace at the instance of Cardinal Wolsey and Dr. Thomas Magnus.