Spain has a highly developed social market economy. It is the world's 14th-largest by nominal GDP, the fourth-largest in the EU, and the sixth-largest in Europe. Spain is a member of the European Union and the eurozone, as well as the OECD and the World Trade Organization. In 2024, Spain ranked as both the 17th-largest exporter and the 17th-largest importer in the world. Spain is listed 28th in the UN Human Development Index and 30th in GDP per capita by the IMF. Some main areas of economic activity are the automotive industry, medical technology, chemicals, shipbuilding, tourism and the textile industry. Among OECD members, Spain has a highly efficient and strong social security system, which comprises roughly 23% of GDP.

During the Great Recession, Spain's economy was also in a recession. Compared to the EU and US averages, the Spanish economy entered recession later, but stayed there longer. The boom of the 2000s was reversed, leaving over a quarter of Spain's workforce unemployed by 2012. In aggregate, GDP decreased almost 9% during 2009–2013. In 2012, the government officially requested a credit from the European Stability Mechanism to restructure its banking sector in the face of the crisis. The ESM approved assistance and Spain drew €41 billion. The ESM programme for Spain ended with the full repayment of the credit drawn 18 months later.

Representing approximately 0.6% of the world's population, Spain accounts for about 1.36% of the global gross domestic product (GDP). This indicates that Spain's GDP per capita is significantly higher than the global average. Specifically, Spain's GDP per capita is approximately 2.55 times (or 255%) the world average, reflecting a relatively high level of economic productivity and development. Consequently, Spain maintains a standard of living that surpasses that of many countries with larger populations but lower economic output per capita.

History

During the first decades of the twentieth century, Spain experienced an accelerated growth of its industrial labor force and urban population; the economy became less agrarian as the process of urbanization spread after 1910. The largest sector was still agriculture but saw declines, along with fishery, relative to the share of active population engaged in the activity. The fastest growing sector at that time was services.

When Spain joined the EEC in 1986 its GDP per capita was about 72% of the average of its members.

At the second half of the 1990s, the conservative government of former prime minister Jose María Aznar had worked successfully to gain admission to the group of countries joining the euro in 1999. By the mid-1990s the economy had commenced the growth that had been disrupted by the global recession of the early 1990s. The strong economic growth helped the government to reduce the government debt as a percentage of GDP and Spain's high unemployment rate began to steadily decline. With the government budget in balance and inflation under control Spain was admitted into the eurozone in 1999. By 2007, Spain had achieved a GDP per capita of 105% of European Union's average due to its own economic development and the EU enlargements to 28 members, which placed it slightly ahead of Italy (103%). Three regions were included in the leading EU group exceeding 125% of the GDP per capita average level: the Basque Country, Madrid, and Navarre.Login required – Eurostat 2004 GDP figures According to calculations by the German newspaper Die Welt in 2008, Spain's economy had been on course to overtake countries like Germany in per capita income by 2011. in October 2006, Unemployment stood at 7.6% which compared favorably to many other European countries, and especially with the early 1990s when it stood at over 20%. In the past, Spain's economy had included high inflation and it has always had a large underground economy.

The turn to growth during the 1997-2007 period produced a real estate bubble fed by historically low interest rates, massive rates of foreign investment (during that period Spain had become a favorite of other European investment banks) and an immense surge in immigration. At its peak in 2007, construction had expanded to 15% of the total gross domestic product (GDP) of the country and 12% of total employment. During that time Spain capital inflows –including short term speculative investment– financed a large trade deficit.

The downside of the real estate boom was a corresponding rise in the levels of private debt, both of households and of businesses; as prospective homeowners had struggled to meet asking prices, the average level of household debt tripled in less than a decade. This placed especially great pressure upon lower to middle income groups; by 2005 the median ratio of indebtedness to income had grown to 125%, due primarily to expensive boom time mortgages that now often exceed the value of the property.

Noticeable progress continued until early 2008, when the 2008 financial crisis burst Spain's property bubble.

A European Commission forecast had predicted Spain would enter the world's late 2000s recession by the end of 2008. At the time, Spain's Economy Minister was quoted saying, "Spain is facing its deepest recession in half a century". Spain's government forecast the unemployment rate would rise to 16% in 2009. The ESADE business school predicted 20%. By 2017, Spain's GDP per capita had fallen back to 95% of the European Union's average.

2008–2014 Spanish financial crisis

Like most economies, Spain's economy had been steadily growing, regardless of political changes e.g. when the ruling party changed in 2004. It maintained robust growth during the first term of prime minister José Luis Rodríguez Zapatero, even though problems were becoming evident. According to the Financial Times, Spain's rapidly growing trade deficit had reached 10% of GDP by summer 2008, the "loss of competitiveness against its main trading partners" and as a part of the latter, inflation which had been traditionally higher than its European competitors. This was especially affected by house price increases of 150% from 1998 and growing private sector indebtedness (115%), chiefly related to the Spanish Real Estate boom and rocketing oil prices.

In April 2008, the Spanish government growth forecast was 2.3%, but this was revised down by the Ministry of Economy to 1.6%. Studies by independent forecasters estimated it had actually dropped to 0.8%, below the strong 3% plus growth rates during 1997–2007. During Q3 of 2008 the GDP contracted for the first time in 15 years. In February 2009, it was confirmed that Spain, along other European economies, had entered recession.

In July 2009, the IMF worsened the estimates for Spain's 2009 contraction, to -4% of GDP, close to the European average of -4.6%. It estimated a further 0.8% contraction for Spain, in 2010. In 2011, the deficit reached a high of 8.5%. For 2016 the deficit objective of the government was around 4%, falling to 3% for 2017. The European Commission demanded 4% for 2016 and 2.5% for 2017.

Property boom and bust, 2003–2014

The adoption of the euro in 2002 had driven down long-term interest rates, prompting a surge in mortgage lending that jumped fourfold from 2000 to its 2010 apex. The growth in the property market, which had begun in 1997, accelerated and within a few years had developed into a property bubble. It was financed largely by "Cajas", which are regional savings banks under the oversight of regional governments, and was fed by the historically low interest rates and a massive growth of immigration. Fueling this trend, the economy was being credited for having avoided the almost zero of some of its largest partners in the EU, in the months previous to the global Great Recession.

Over the five years ending 2005, Spain's economy had created more than half of all new jobs in the EU. At the top of its property boom, Spain was building more houses than Germany, France and the UK combined. Home prices soared by 71% between 2003 and 2008, in tandem with the credit explosion.

The bubble imploded in 2008, causing the collapse of Spain's large property related and construction sectors, causing mass layoffs, and a collapsing domestic demand for goods and services. Unemployment shot up. At first, Spain's banks and financial services avoided the early crisis of their international counterparts. However, as the recession deepened and property prices slid, the growing bad debts of the smaller regional savings banks, forced the intervention of Spain's central bank and government through a stabilization and consolidation program, taking over or consolidating regional "cajas", and finally receiving a bank bailout from the European Central Bank in 2012, aimed specifically for the banking business and "cajas" in particular. Following the 2008 peak, home prices plunged by 31%, before bottoming out in late 2014.

The economic situation started improving by 2013. By then, Spain managed to reverse the record trade deficit which had built up during the boom years. It attained a trade surplus in 2013, after three decades of running a deficit. In 2015, GDP grew by 3.2%: a rate not seen since 2007. In 2014–2015, the economy recovered 85% of the GDP lost during the 2009–2013 recession. This success led some analysts to refer to Spain's recovery as "the showcase for structural reform efforts". Spain's unemployment fell substantially from 2013 to 2017. Real unemployment is much lower, as millions work in the grey market, people who count as unemployed yet perform jobs. Real Spanish GDP may be around 20% bigger, as it is assumed the underground economy is annually 190 billion euros (US$224 billion). Among high income European countries, only Italy and Greece are believed to have larger underground economies. Thus Spain may have higher purchasing power as well as a smaller gini coefficient (inequality measure), than shown in official numbers.

Euro debt crisis, 2010-2012

In the first weeks of 2010, renewed anxiety about excessive debt in some EU countries and, more generally, about the health of the euro spread from Ireland and Greece to Portugal, and to a lesser extent Spain. Many economists recommended a battery of policies to control the surging public debt caused by the recessionary collapse of tax revenues, combining drastic austerity measures with higher taxes. Some German policymakers went as far as to say that bailouts should include harsh penalties to EU aid recipients, such as Greece. The Spanish government budget was in surplus in the years immediately before the Great Recession, and its debt was not considered excessive.

At the beginning of 2010, Spain's public debt as a percentage of GDP was still less than those of Britain, France or Germany. However, commentators pointed out that Spain's recovery was fragile, that the public debt was growing quickly, troubled regional banks may need large bailouts, growth prospects were poor and therefore limiting revenue, and that the central government had limited control over the spending of the regional governments. Under the structure of shared governmental responsibilities that has evolved since 1975, much responsibility for spending had been given back to the regions. The central government found itself in the position of trying to gain support for unpopular spending cuts from the recalcitrant regional governments. In May 2010, the government announced further austerity measures, consolidating the ambitious plans announced in January.

As of September 2011, Spanish banks held a record high of €142 billion of Spanish national bonds. Till Q2 2012, Spanish banks were allowed to report real estate related assets in higher non-market price by regulators. Investors who bought into such banks must be aware. Spanish houses cannot be sold at land book value after being vacant over a period of years.

Employment crisis