The town was granted its market charter sometime in the 12th Century, perhaps around the same time the castle was built.