The boom
After the end of the dictatorship, and especially after joining the EEC in 1986, Spain enjoyed a long period of growth that in the 1990s and early 2000s seemed unstoppable: foreign trade, foreign investment drawn by relatively low labour costs, rising tourism and effective use of European funds. Growth rates were consistently above the European average and unemployment fell from 22% to 8%. But a huge part of that growth came from construction: in 2006 Spain was building more homes than Germany, France and Italy combined, financed by easy mortgages granted above all by the cajas de ahorro, the regional savings banks, often controlled by local politicians.
The crash
With the global financial crisis of 2008 the bubble burst. At the end of 2008 GDP contracted for the first time in fifteen years, and in 2009 Spain officially entered recession. Construction came to a standstill: half a million finished homes went unsold, whole new neighbourhoods stood empty and hundreds of thousands of construction workers lost their jobs. Zapatero's government, accused of long denying the seriousness of the crisis, first tried to prop up the economy with a vast public works programme, then, under market pressure, began the first cuts. In 2011 he stepped down early, and the November election was won with an absolute majority by Mariano Rajoy's Partido Popular (see elections).
2012: the bank bailout
The most dramatic moment was 2012. Losses on property loans crippled many savings banks, and the largest, Bankia, had to be nationalised. Rajoy's government asked the European Union for a loan of up to 100 billion euros to recapitalise the banking system, of which about 41 billion were used. Interest on government bonds exceeded 7% and the spread over German Bunds hit record levels. Unemployment reached 26% in 2013, and youth unemployment exceeded 55%.
To cut the deficit the government passed very heavy cuts: scrapping the extra month's pay for public employees, reducing unemployment benefits, raising VAT from 18 to 21%, cuts to health and education, and a labour reform that made dismissals easier and cheaper. The protests were huge: from the indignados movement of 15 May 2011, which occupied Madrid's Puerta del Sol, to the marches of Asturian miners against the early closure of the mines, to campaigns against the evictions (desahucios) of hundreds of thousands of families who could no longer pay their mortgages.
The consequences
The crisis drove hundreds of thousands of young Spaniards to emigrate, to Germany, the UK and Latin America, and halted immigration for several years. It also changed politics, ending two-party rule with the rise of Podemos and Ciudadanos (see politics in Spain).
The recovery
From 2014 Spain grew again, thanks to exports, tourism, innovation in fields such as renewable energy and pharmaceuticals, and the international expansion of its companies in Latin America, China and India. The banking system, restructured with the disappearance of almost all the savings banks, came out stronger. But the scars of the crisis, from precarious work for the young to the housing problem, are still felt today (see the economy of Spain and Spain today).