Little is known about the early history of Haddington. The Burgh was founded by King David I and a church dedicated to the Virgin was granted by the king in about 1134 to the church of St Andrews. Then, sometime between 1153 and 1178 Alexander de St Martin was given lands near Haddington by the Countess Ada (widow of Prince Henry, son of King David I); it is not known if this included the present church. In 1178, Ada founded a priory (nunnery) in Haddington and Alexander de St Martin appears to have gifted the lands and buildings of St Martinsgate to this. At a later date, it is known that the nunnery held courts ‘apud Ecclesiam S. Martini in lie Nungait’. In 1567, the prioress disposed of the priory lands, which were then conferred by Queen Mary on William Maitland of Lethington.