They were first brought under the control of Gonçalo Egas, having been granted a Foral charter to the town aiming to encourage their settlement and defense in 1226.
A will date from this period under the reign of Sancho II (1223–1248), directing the reconstruction of the fortification.
In 1580, the castle was brought under Habsburg control when Portugal joined Spain in the Iberian Union.
The castle was constructed during the Middle Ages, built with a combination of shale stone, marble and granite.
The renovations of the seventeenth century involved fixing the bastions at the corner of the walls and ravelins in front of the curtains.