Spain's location at the crossroads of the Atlantic and the Mediterranean, Europe and Africa, has made it a key political and cultural bridge across five continents.
Through exploration and conquest, Spain became a world power in the 16th century, and maintained a vast overseas empire until the 19th century.
Its modern history was marked by the bitter civil war of 1936-39, and the ensuing decades-long dictatorship of Francisco Franco.
Since General Franco's death in 1975, Spain has made the transition to democracy, and built a modern economy.
The country's 17 regions have their own directly-elected authorities, but separatism remains a live issue in wealthy Catalonia in the north-east.
Kingdom of Spain
Population 46.7 million
Area 505,988 sq km (195,363 sq miles)
Languages Spanish (Castilian), Catalan and its variant Valencian, Gallego (Galician), Euskera (Basque)
Major religion Christianity
Life expectancy 79 years (men), 85 years (women)
Head of state: King Felipe VI
King Felipe succeeded to the throne on the abdication of his father Juan Carlos in June 2014.
Born in 1968 when his father was heir-apparent to the vacant throne during the Franco dictatorship, Prince Felipe was educated for his future royal role and undertook official engagements on behalf of the king from 1995.
Despite retaining considerable constitutional power as chief executive and commander-in-chief, King Felipe has pledged to continue his father's legacy of supporting the primacy of parliament.
Prime Minister: Pedro Sánchez
Socialist leader Pedro Sánchez took over as prime minister in June 2018, after his conservative predecessor Mariano Rajoy lost a parliamentary vote of confidence.
This was triggered by a long-running corruption trial involving members of Mr Rajoy's Popular Party.
Snap elections in April and November 2019 boosted the Socialists, but they fell short of a majority, while Vox became first far-right party to win seats since the death of Francisco Franco in 1975.
In January 2020, Mr Sánchez formed a minority coalition government with the left-wing Podemos party after winning a narrow parliamentary vote of confidence.
Public broadcaster RTVE shares the market with major commercial operators. Regional TV networks are operated by their respective governments.
Freedom House NGO raises concerns about the concentration of media ownership and what it says is political interference in public media.
There are more than 40 million internet users. Facebook is the leading social platform.
Some key dates in Spain's history:
16th-17th centuries - Spanish Empire at its height, with Spain the predominant European power. The rise of Protestant states in northern Europe and the Ottoman Empire in the Mediterranean begin the country's gradual decline.
18th century - The War of the Spanish Succession loses Spain its European possessions outside the Iberian Peninsula.
Bourbon dynasty, originally from France, centralises the Spanish state, shutting down many regional autonomous assemblies and modernising government and the military.
19th century - Napoleonic legacy of political division and economic dislocation leaves Spain weak and unstable, with frequent changes of government and a low-level insurgency by Carlist supporters of a rival branch of the royal family.
All Latin American colonies win their independence, with Cuba, Puerto Rico and the Philippines in Asia lost during a disastrous war with the United States in 1898.
1936-39 - Spanish Civil War pits left-wing Republicans against right-wing Nationalists, with both sides receiving foreign support.
General Francisco Franco leads the Nationalists to victory, and remains in power till his death in 1975.
1975 - Franco dies. Succeeded as head of state by King Juan Carlos. Spain makes transition from dictatorship to democracy and withdraws from the Spanish Sahara, ending its colonial empire.
1978 - New constitution confirms Spain as a parliamentary monarchy.
1986 - Spain joins European Economic Community.
2017 - Madrid imposes direct rule in Catalonia after a referendum backs independence from Spain.
Read full timeline