Spain, is a country located in Southwestern Europe, with parts of its territory in the Atlantic Ocean, in the Mediterranean Sea and in Africa. It is the largest country in Southern Europe and the fourth-most populous European Union member state. Spanning across the majority of the Iberian Peninsula, its territory also includes the Canary Islands in the Atlantic Ocean, the Balearic Islands in the Mediterranean Sea, and the autonomous cities of Ceuta and Melilla in Africa. Peninsular Spain is bordered to the north by France, Andorra, and the Bay of Biscay; to the east and south by the Mediterranean Sea and Gibraltar; and to the west by Portugal and the Atlantic Ocean. Spain's capital and largest city is Madrid; other major urban areas include Barcelona, Valencia, Zaragoza, Seville, Málaga, Murcia, Palma de Mallorca, Las Palmas de Gran Canaria, and Bilbao
From 711 to 718, as part of the expansion of the Umayyad Caliphate, which had conquered North Africa from the Byzantine Empire, nearly all of the Iberian Peninsula was conquered by Muslims from across the Strait of Gibraltar, resulting in the collapse of the Visigothic Kingdom. Only a small area in the mountainous north of the peninsula stood out of the territory seized during the initial invasion. The Kingdom of Asturias-León consolidated upon this territory. Other Christian kingdoms such as Navarre and Aragon in the mountainous north eventually surged upon the consolidation of counties of the Carolingian Marca Hispanica.
Upon the conclusion of the Granada War, the Nasrid Sultanate of Granada (the remaining Muslim-ruled polity in the Iberian Peninsula after 1246) capitulated in 1492 to the military strength of the Catholic Monarchs, and it was integrated from then on in the Crown of Castile.en.wikipedia.org