In 955 Almería gained the title of medina ("city") by the Caliph of Cordoba, Abd ar-Rahman III: construction of the defensive citadel, located in the upper sector of the city, began in this period.
The complex was enlarged under caliph Al-Mansur and, later, under Al-Jairan, first king of the independent taifa of Almería (1012-1028).