In 715, the site was occupied by the Moors.
The site was conquered in the 11th century by Ferdinand, King of León, but held for little time. It was definitively occupied in 1249 by D. Paio Peres Correia. Several years later (1268) Afonso III had the area populated after reconstructing and expanding the walls. During this period two of the main towers, including the keep tower, were constructed, but the six gates suggest the existence of other towers (only ruins remain). A foral (charter) was issued in 1266 from Lisbon by Afonso III of Portugal.
Between 9–12 April 1359, King Peter I overnighted at the alcaidaria.
In 1422 or 1462, Henrique de Meneses, 1st Count of Loulé re-built the towers and walls of the castle.
A new foral was issued by Manuel of Portugal in 1501.
King Sebastian of Portugal overnighted on 29 January 1573.
The castle was damaged during an earthquake in 1969.
The site was taken-over by the Instituto Português do Património Arquitetónico, on 1 June 1992, under Decree 106F/92 (Diário da Republic, Série IA, 126). In 2001 a protocol was signed between the municipal council and the DGEMN in order to facilitate the protection and conservation of the patrimony in the municipality, that included the castle grounds. This document was supplemented on 18 January 2013 (Diário da República, Série II, 13, Anúncio de Procedimento 232/2013) relative to the remodeling of the Praça D. Afonso III, Rua D. Paio Peres Correia and Largo das Bicas Velhas (Chafariz).