In 1197 a castle was built by the River Ayr. Shortly afterwards, in 1205, King William the Lion created a burgh at Ayr. On April 26, 1315, the first Parliament of Scotland was held in Ayr by Robert The Bruce at St.John's Tower by the sea. It was once known as 'Inverair/Inverayr' and this usage is still retained in the Scottish Gaelic form of the name Inbhir Air.
Later, during Cromwellian times, the town was used as a base and fortress for some of his men. Cromwell built a huge wall around certain areas of the town, most of which can still be seen today.