The castle stands on a prominent rocky ridge above the village. The fortress, although the ramparts are reminiscent of Moorish castles, was built by the Christian king of Castile, Sancho IV in the thirteenth century replacing a much smaller fortress which had been built earlier by the Muslim rulers of Andalucía. The Muslim structure is thought to have been built on top a much early Roman fortification. The castle was part of a defence system built to protect the city of Seville from the Portuguese. This defence system was called the Banda Gallega or The Galician Band. The system composed of three lines of defence, which mostly utilized older Moorish fortresses. The first line contained the castles of Aroche, Encinasola and Fregenal de la Sierra. In the second line was the Torre of San Bartolomé and Cortegana castle. The third line included Santa Olalla del Cala and the fortress at Aracena.