The town is named after Saint Andrew the Apostle. The settlement grew to the west of St Andrews Cathedral, with the southern side of the Scores to the north and the Kinness Burn to the south. The burgh soon became the ecclesiastical capital of Scotland, a position which was held until the Scottish Reformation. The famous cathedral, the largest in Scotland, now lies in ruins. St Andrews Cathedral was once the largest building in Europe.
The castle was first erected around 1200 as the residence, prison and fortress of the bishops of the diocese. Several reconstructions occurred in subsequent centuries, most notably due to damage incurred in the Wars of Scottish Independence.