After the conquest, the Order of the Temple settled in this borderline area and constructed an imposing castle on the structure of a former Andalusian fortification. During the first half of the 14th century, the Order of the Knights Hospitallers took over the castle and reconditioned the building.