In the time of the Arabs it was called Ellerina, a place contested between Arabs and Christians. It was definitively occupied in the year 1243 by Pelayo Pérez Correa, master of the Order of Santiago, to whom Ferdinand III of Castile had entrusted the reconquest of Sierra Morena.