Spain, officially the Kingdom of Spain (Spanish: Reino de España), is a country in Southwestern Europe with some pockets of territory in the Mediterranean Sea, offshore in the Atlantic Ocean and across the Strait of Gibraltar. Its continental European territory is situated on the Iberian Peninsula, and its insular territory includes the Balearic Islands in the Mediterranean Sea, several small islands in the Alboran Sea and the Canary Islands in the Atlantic Ocean. The Spanish territory also includes the African semi-exclaves of Ceuta, Melilla and Peñon de Vélez across the Strait of Gibraltar. The country's mainland is bordered to the south by Gibraltar, to the south and east by the Mediterranean Sea; to the north by France, Andorra and the Bay of Biscay; and to the west by Portugal and the Atlantic Ocean.
With an area of 505,990 km2 (195,360 sq mi), Spain is the largest country in Southern Europe, the second-largest country in Western Europe and the European Union, and the fourth-largest country by area on the European continent. With a population exceeding 47.4 million, Spain is the sixth-most populous country in Europe, and the fourth-most populous country in the European Union. Spain's capital and largest city is Madrid; other major urban areas include Barcelona, Valencia, Seville, Zaragoza, Málaga, Murcia, Palma de Mallorca, Las Palmas de Gran Canaria and Bilbao.
Anatomically modern humans first arrived in the Iberian Peninsula around 42,000 years ago. The first cultures and peoples that developed in current Spanish territory were Pre-Roman peoples such as the ancient Iberians, Celts, Celtiberians, Vascones, and Turdetani. Later, foreign Mediterranean peoples such as the Phoenicians and ancient Greeks developed coastal trading colonies, and the Carthaginians briefly controlled part of the Spanish Mediterranean coastline. From the year 218 BCE, with the taking of the city of Ampurias, the Roman colonization of Hispania began and, with the exception of the Atlantic cornice, they quickly controlled the territory of present-day Spain. The Romans had driven the Carthaginians out of the Iberian peninsula by 206 BCE, and divided it into two administrative provinces, Hispania Ulterior and Hispania Citerior. The Romans laid the foundations for modern Spanish culture and identity, and was the birthplace of important Roman emperors such as Trajan, Hadrian or Theodosius I.
Spain remained under Roman rule until the collapse of the Western Roman Empire in the fourth century, which ushered in Germanic tribal confederations from Central and Northern Europe. During this period, present-day Spain was divided between different Germanic powers, including the Suevi, Alans, Vandals and Visigoths, the latter maintaining an alliance with Rome via foedus, while part of Southern Spain belonged to the Byzantine Empire. Eventually, the Visigoths emerged as the dominant faction by the fifth century, with the Visigothic Kingdom spanning the vast majority of the Iberian Peninsula, and established its capital in what is now the city of Toledo. The creation of the code of laws Liber Iudiciorum by the King Recceswinth during the Visigothic period deeply influenced the structural and legal bases of Spain and the survival of Roman Law after the fall of the Roman Empire.
In the early eighth century, the Visigothic Kingdom was invaded by the Umayyad Caliphate, ushering in over 700 years of Muslim rule in Southern Iberia. During this period, Al-Andalus became a major economic and intellectual center, with the city of Córdoba being among the largest and richest in Europe. Several Christian kingdoms emerged in the northern periphery of Iberia, chief among them León, Castile, Aragón, Portugal, and Navarre. Over the next seven centuries, an intermittent southward expansion of these kingdoms—metahistorically framed as a reconquest, or Reconquista—culminated with the Christian seizure of the last Muslim polity, the Nasrid Kingdom of Granada, and the control of all Iberia by the Christian kingdoms in 1492. That same year, Christopher Columbus arrived in the New World on behalf of the Catholic Monarchs, whose dynastic union of the Crown of Castile and the Crown of Aragon is usually considered the emergent Spain as a unified country. During the centuries after the Reconquista, the Christian kings of Spain persecuted and expelled ethnic and religious minorities such as Jews and Muslims through the Spanish Inquisition.
From the 16th until the early 19th century, Spain ruled one of the largest empires in history. It was among the first global empires, and its immense cultural and linguistic legacy includes over 570 million Hispanophones, making Spanish the world's second-most spoken native language. Spanish art, music, literature and cuisine have been influential worldwide, particularly in the Americas. As a reflection of its large cultural wealth, Spain has the world's fourth-largest number of World Heritage Sites (49) and is the world's second-most visited country.
Today, Spain is a secular parliamentary democracy and a constitutional monarchy, with King Felipe VI as head of state. It is a highly developed country and a high income country, with the world's fourteenth-largest economy by nominal GDP and the sixteenth-largest by PPP. Spain has one of the longest life expectancies in the world at 83.5 years in 2019. It ranks particularly high in healthcare quality, with its healthcare system considered to be one of the most efficient worldwide. It is a world leader in organ transplants and organ donation. Spain is a member of the United Nations (UN), the European Union (EU), the Eurozone, the Council of Europe (CoE), the Organization of Ibero-American States (OEI), the Union for the Mediterranean, the North Atlantic Treaty Organization (NATO), the Organisation for Economic Co-operation and Development (OECD), Organization for Security and Co-operation in Europe (OSCE), the World Trade Organization (WTO) and many other international organisations.