Given its privileged location, overlooking the vast territories of the North that shape the La Campiña, there is evidence of human settlements since very early times. The Castle started as an Ibero-Turdetan defensive bastion in the 5th century BC. When the Carthaginians arrived 200 years later, it became a watchtower. In the 5th century, the compound was enlarged by the Romans and became increasingly important, in particular, to defend the territory against Barbarian invasions. The Muslims occupied the Roman “Castelo”, using it as a defensive bastion that they called “Alcazaba”. The trove of ceramic objects and coins found in the Castle reveal the importance of the Muslims during this period.
In the 13th century, King Fernando III The Saint began his reconquest, and this place became part of the so-called Banda Morisca, the medieval name of the border with the Kingdom of Granada. Henceforth, the Castle became a point of defence and watchtower against the Muslim raids from the Ronda mountain range.
The Castle had different owners until King Alfonso X transferred it to the Military Order of Calatrava. The Order carried out extensive renovations to one of the lower naves, which was meant to be a chapel consecrated to Our Lady of Virtues. Today, this image is the patron saint of the town and the titular image of the parish that bears her name.
The Order owned the Castle until Pedro Téllez Girón convinced King Enrique IV to gift him the building for his personal estate. Not long passed before he took the necessary measures to repopulate the area following the expulsion of the Muslims in 1264. Under the authority of the Castle, the Municipal Charter (Carta-Puebla) which mandated the creation of the current village was issued.