Spain, or the Kingdom of Spain (Reino de España), is a transcontinental country predominantly located in southwestern Europe with parts of territory in the Atlantic Ocean and across the Mediterranean Sea. The largest part of Spain is situated on 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. 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 second-largest country in the European Union (EU) and, with a population exceeding 47.4 million, the fourth-most populous EU member state. 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. Pre-Roman peoples dwelled in the territory, in addition to the development of coastal trading colonies by Phoenicians and Ancient Greeks and the brief Carthaginian rule over the Mediterranean coastline. The Roman conquest and colonization of the peninsula (Hispania) ensued, bringing a Roman acculturation of the population. Hispania remained under Roman rule until the collapse of the Western Roman Empire in the fourth century, which ushered in the migration of Germanic peoples and the Alans into the peninsula. Eventually, the Visigoths emerged as the dominant power in the peninsula by the fifth century. In the early eighth century, most of the peninsula was conquered by the Umayyad Caliphate and during early Islamic rule, Al-Andalus became the dominant peninsular power, centered in Córdoba. Several Christian kingdoms emerged in Northern Iberia, chief among them León, Castile, Aragón, Portugal, and Navarre and over the next seven centuries, an intermittent southward expansion of these kingdoms, known as Reconquista, culminated with the Christian seizure of the Emirate of Granada in 1492. Jews and Muslims were forced to choose between conversion to Catholicism or expulsion and the Morisco converts were eventually expelled. The dynastic union of the Crown of Castile and the Crown of Aragon was followed by the annexation of Navarre and the 1580 incorporation of Portugal (which ended in 1640). In the wake of the Spanish colonization of the Americas after 1492, the Crown came to hold a large overseas empire, which underpinned the emergence of a global trading system primarily fuelled by the precious metals extracted in the New World. Centralisation of the administration and further State-building in mainland Spain ensued in the 18th and 19th centuries, during which the Crown saw the loss of the bulk of its American colonies a few years after of the Peninsular War. The country veered between different political regimes; monarchy and republic, and following a 1936–39 devastating civil war, a fascist dictatorship that lasted until 1975. With the restoration of Democracy under the Spanish Constitution of 1978 and the entry into the European Union in 1986, the country experienced profound social and political change as well as an important economic growth.
Spanish art, music, literature and cuisine have been influential worldwide, particularly in Western Europe and 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. Its cultural influence extends over 570 million Hispanophones, making Spanish the world's second-most spoken native language.Spain is a developed country, a secular parliamentary democracy and a constitutional monarchy, with King Felipe VI as head of state. It is a high-income country and an advanced economy, 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.