The castles in Spain were built mainly for the country's defense, particularly with respect to fortification. During the Middle Ages, northern Christian kingdoms had to secure their borders with their Muslim southern neighbours, thus forcing both Christian and Muslim kings to grant border fiefs to their liege noblemen so as to keep and maintain defensive fortresses. When the Reconquista advanced, those border castles lost their initial purpose, and, as in the rest of medieval Europe, they were used as noble residences and fief-keeps. Sporadic threats of war maintained their initial military purposes as enemy invasions were common. In some locations, such as the Basque country, fiefdoms did not exist as such, and noble families could not afford nor did they need huge fortresses, giving rise to many tower houses. In Muslim Spain many castle-palaces were built: the petty taifa kingdoms that arose after the fall of the Caliphate of Córdoba were militarily weak thus castles began taking on a more aesthetic purpose. During the late Middle Ages, Christian kingdoms had secured and enriched themselves well enough to support a more courtly lifestyle, so more residential castles were built, such as the Alcázar of Segovia, which was used as the main residence of the kings of Castile, whereas the Castle of Olite, built in a luxurious gothic style, was the seat of the Kingdom of Navarre's royal court.

After the Conquest of Granada in 1492, the Catholic monarchs ordered all the castles in their realms to be handed over to the Crown. Although the order was not completely carried out, the War of the Germanias, a rebellion against king Charles V in the early 16th century, forced the new Spanish Habsburg dynasty to continue the process, and many castles were demolished as well. Most of the castles in Spain were successively abandoned and dismantled, Spanish kings fearing noble and peasant revolts, especially in the newly conquered lands. Accordingly, some of them are nowadays in a state of decay, and although some restoration work has been done, the number of former castles is so large that the Spanish government lacks both the resources and the will to restore them all.

Almería

Cádiz

Córdoba

Granada

Huelva

Jaén

Málaga

Sevilla

Huesca

Castle of Arrés Castle of Alquezar Castle Palace of Argabieso Castle of Benabarre Castle of Boltaña Castle of Fantova Castle of Loarre Castle of Marcuello Castle of Monzón Castle of Montearagón Castle of Samitier Castle of Torres-Secas Citadel of Jaca Tower of Fiscal Walls of Antillón

Teruel

Castle of Albarracín Castle of Alcalá de la Selva Castle of Calanda Castle of Alcañiz Castle of Mora de Rubielos Castle of Ojos Negros Castle of Peracense Castle of Puertomingalvo Castle of Tornos Castle of Valderrobres Castle of Villel

Zaragoza

Castle of Aljafería Castle of Aranda de Moncayo Castle of Bichuesca Castle of Arandiga Castle of Grisel Castle of Biel Castle of Daroca Castle of Exarc de Moncayo Castle of Luesia Castle of Mesones de Isuela Castle of Sadaba Castle of Sibirana Castle of Trasmoz Castle of Uncastillo Castle of la Zuda (Borja) Castle Mayor (Daroca) Torreón of La Zuda Walls of Zaragoza

Castle of Alba (Quirós) Castle of Alba (Somiedo) Castle of Alesga Castle of Campogrande Castle of Las Caldas Castle of la Cabezada Castle of Gauzón Castle of Peña Manil Castle of Salas Castle of San Martín Castle of Soto (Aller) Castle of Soto (Ribera de Arriba) Castle of Soto de los Infantes Castle of Tudela Castle of Villademoros Castle of Villamorey Palace Ferrera (Báscones) El Torreón Torreón of Llanes Torreón of Ludeña Torreón of Peñerudes Tower del Valledor Tower of the Castle of Yabio Tower of los Valdés Tower of Proaza Tower of la Quintana Tower of los Valdés Tower of San Julián Tower of Tronquedo Walls of Oviedo

Araba Castle of Zabala Castle of Gebara Castle of Eskibel Castle of Ocio Roman oppidum of Iruña-Veleia Tower of Mendoza Tower of los Varona Tower of Barrón Tower of Doña Otxanda in Vitoria-Gasteiz Tower of Orgaz and Tower of Kondestable Tower Negorta Tower-House of Calderondar eta Salazatar Tower-House of Galartza Walls of Vitoria-Gasteiz Old town of Vitoria-Gasteiz Walled town of Labraza Walled town of Antoñana Walled town of Laguardia Walled town of Gatzaga Buradon Walled town of Urizaharra

Gipuzkoa

Castle of Gaztelu Zahar Castle of Charles V Castle of la Mota in the Mount Urgull in San Sebastián Castle of Atxorrotx Fort of San Marcos Tower Idiakez Tower of Sasiola Tower Zumeltzegi Tower-House Enparan Walled town of Hondarribia Walled town of Leintz-Gatzaga

Biscay Castle of Butrón Castle of Empress Eugénie de Montijo Castle of Muñatoizko San Martin Castle of Malmasin Complex of coastal fortresses of the Mount Serantes Fort of la Galea Torre Loizaga Tower of Lezama Tower Malpika Tower of Salazar Tower of Zamudio Tower Martiartu Tower of Muntsaratz Tower-House Likona Tower-House of Urrutia Walled town of Bermeo

Castle of Alaró Castle of Amer Bellver Castle St. Philip's Castle, Mahón Castle of Bendinat Castle of Cabrera (Cabrera island)es Castle of Capdepera Castle of Pollensaes Castle of Santa Àgueda Castle of Santueri Fortress of Sant Carles Fortress of Isabella II

Castle of la Luz Castle of Mata Castle of San Felipe (Puerto de la Cruz) Castle of San Francisco (Las Palmas de Gran Canaria) Castle of San Miguel (Garachico) Castle of Guanapay Castle of Paso Alto (Santa Cruz de Tenerife) Castle of San Joaquín Castle of San Cristóbal (Santa Cruz de Tenerife) Castle of San Cristóbal (Las palmas de Gran Canaria) Castle of St John the Baptist Castle of San Andrés Fortress of Santa Catalina (Las Palmas de Gran Canaria) Fort of Almeyda

Castle of Aldueso Castle of Allendelagua Castle of Agüero Castle of Argüeso Castle of Castro Urdiales Castle of Cobejo Castle of El Collado Castle of El Haya Castle of Montehano Castle of Piñeres Castle of Pedraja Castle of San Felices de Buelna Castle of San Vicente de la Barquera Castle of Suances Castle of Treceño Castillo de Villamoñico Castle of Villegas Castle of Vispieres Palace of Riva-Herrera Fort del Mazo Battery of San Martín Battery of San Martín Alto Battery of San Pedro del Mar Low Battery of Galvanes

Ávila Castle of La Adrada Castle of Don Álvaro de Luna (Arenas de San Pedro) Castle of Arévalo Castle of the Alcázar (Ávila) Castle of El Barco de Ávila Castle of Bonilla de la Sierra Castle of Zurraquín (Cabezas del Villar) Castle of El Mirón Castle of Aunqueospese (Mironcillo) Castle of Mombeltrán Castle of the Duke of Montellano (Narros de Saldueña) Castle Count of Rasura (Rasueros) Castle of Castronuevo (Rivilla de Barajas) Castle of Villaviciosa (Solosancho) Castle of Villatoro (Villatoro) Castle-Palace of Magalia (Las Navas del Marqués) Walls of Ávila

Burgos Castle of Albillos (Villagonzalo-Pedernales) Castle of Arenillas de Muñó (Estepar) Castle of Belorado Castle of Burgos Castle of los Cartagena (Olmillos de Sasamón) Castle of Castrojeriz Castle of Coruña del Conde Castle of the Dukes of Frías (Frías) Castle of Espinosa de los Monteros (Espinosa de los Monteros) Castle of Frías Castle of Haza Castle of La Loja (Quintana de Valdivieso) Castle of Malvecino (Población de Valdivieso) Castle of Miranda de Ebro Castle of Monastery of Rodilla Castle of Olmillos de Sasamón Castle of Pancorbo Castle of Peñaranda de Duero (Peñaranda de Duero) Castle of Picón de Lara (Lara de los Infantes) Castle of Poza (Poza de la Sal) Castle of Rebolledo (Rebolledo de la Torre) Castle of Santa Gadea del Cid Castle of Sotopalacios Castle of Tedeja (Trespaderne) Castle of Torregalindo Castle of Torrepadierne (Pampliega) Castle of Úrbel (Urbel del Castillo) Castle of Villaute (Villaute) Castle of Virtus (Virtus) Castle of Velasco Castle of Zumel Fortress of Santa Engracia Arco de Santa María Tower of Bonifaz (Lomana) Tower of Loja Walls of Burgos

León Castle of Alba (Llanos de Alba) Castle of Alcuetas or Tower of Alcuetas (Villabraz) Castle of Alija del Infantado or Castle of los Pimentel (Alija del Infantado) Castle of los Álvarez Acebedo (Valdepiélago) Castle of Arbolio (Valdepiélago) Castle of Aviados (Valdepiélago) Castle of Balboa (Balboa) Castle of Beñal (Riello) Castle of Los Barrios de Gordón (La Pola de Gordón) Castle of Castrocalbón (Castrocalbón) Castle of Cea (Cea) Castle of Cornatel or Castle of Ulver (Priaranza del Bierzo) Castle of Corullón (Corullón) Castle of Coyanza or Castle of Valencia de Don Juan (Valencia de Don Juan) Castle of Ferreras (Valderrueda) Castle of Grajal (Grajal de Campos) Castle of Laguna de Negrillos (Laguna de Negrillos) Castle of Luna (Los Barrios de Luna) Castle of Mansilla de las Mulas (Mansilla de las Mulas) Castle of Nogarejas (Castrocontrigo) Castle of Palacios de Valduerna or Castle of los Bazán (Palacios de la Valduerna) Castle of Peñarramiro (Truchas) Castle of Ponferrada, Castle of the Templars or Castle del Temple (Ponferrada) Castle of Portilla or Castle of the Queen Berenguela (Boca de Huérgano) Castle of los Quiñones (Quintana del Marco) Castle of Riaño (Riaño) Castle of Santa María de Ordás or Tower of Ordás (Santa María de Ordás) Castle of Sarracín, Castle of Vega de Valcarce or Castrum Sarracenicum (Vega de Valcarce) Castle of Siero (Siero de la Reina, Boca de Huérgano) Castle of Tapia or Tower of Tapia (Rioseco de Tapia) Castle of the Towers, Puerta Castillo or Arco de la Cárcel (León) Castle of Villalobos (Valderas) Castle of Villanueva de Jamuz (Santa Elena de Jamuz) Castle of Villapadierna (Cubillas de Rueda) Castle of Turienzo or Tower of los Osorio (Turienzo de los Caballeros) Castle-Palace de los Quiñones (San Emiliano) Castle-Palace of los Marqueses de Villafranca (Villafranca del Bierzo) Castle-Palace of Renedo de Valdetuéjar (Renedo de Valdetuéjar) Castle-Palace of Almanza (Almanza) Castle-Palace of los Guzmanes (Toral de los Guzmanes) Castle-Palace of los Tovar or Torreón of los Tovar (Boca de Huérgano) Tower of Babia (Babia) Tower of Canseco (Canseco, Cármenes) Tower of Fresno de la Valduerna (Villamontán de la Valduerna) Tower of Laguna de Somoza (Val de San Lorenzo) Tower of Puebla de Lillo (Puebla de Lillo) Tower of La Vecilla (La Vecilla de Curueño) Tower of La Vid (La Pola de Gordón)

Palencia Castle of Abia de las Torres Castle of Aguilar de Campoo Castle of Ampudia Castle of Amusco Castle of Antigüedad Castle of Astudillo Castle of Autilla del Pino Castle of Autillo de Campos Castle of Belmonte de Campos (Belmonte de Campos) Castle of Agüero (Buenavista de Valdavia) Castle of Castrillo de Villavega Castle of las Cabañas de Castilla Castle of Sarmiento (Fuentes de Valdepero) Castle of Monzón de Campos Castle of Gama Castle of Hornillos de Cerrato Castle of Palenzuela Castle of the Counts of Saldaña Castle of la Estrella de Campos (Torremormojón) Castle of Valderrábano Castle of Villanueva de la Torre (Barruelo de Santullán)

Salamanca Alcázar of Salamanca Castle of Ledesma Castle of Alba de Tormes Castle of Ciudad Rodrigo or Castle of Henry II of Castile Castle of Ledesma Castle of Sobradillo Castle of Béjar Castle of Miranda del Castañar Castle of Monleón Castle of Montemayor del Río Castle of Puente del Congosto Castle of San Felices de los Gallegos Castle del Buen Amor or Castle of Villanueva de Cañedo Castle of San Martín del Castañar Royal Fortress of the Concepcion or Castillo de Aldea del Obispo

Segovia Alcázar of Segovia Castle of Castilnovo Castle of Coca (Coca) Castle of Cuéllar Castle of Pedraza (Pedraza) Castle of Turégano

Soria

Castle of Almenar (Almenar de Soria) Castle of Berlanga (Berlanga de Duero) Castle of Osma (El Burgo de Osma) Castle of Calatañazor