From old-school family values to women's rights and gay marriage, Spanish society transformed in the four decades of King Juan Carlos's reign.
The democratic rebirth he oversaw spawned fast but fragile economic growth that later plunged Spain into economic crisis, however.
When a 37-year-old Juan Carlos was crowned on November 22, 1975, he took the throne of a deeply conservative society. After 40 years under the dictatorship of Francisco Franco, Spain was just starting to reap the fruits of industrial development.
A November 1975 file photo shows Juan Carlos pledging allegiance to Spain's laws in front of parliament [EPA]
Since then, "the main changes have been economic growth, immigration, women joining the job market and public life, and an international openness," said Maria Angeles Duran, of the state research body CSIC.
Annual average income in Spain rose from $17,170 to $30,890 between 1980 and 2011, according to adjusted data from Spain's central bank.
Jose Bono, a former defence minister, recalled how relatively undeveloped the Castile-La Mancha region was when he became its president in 1983.
"There were 80,000 homes that had no indoor bathrooms, 108 villages that had no electricity, there was not one single kilometre of highway," he said.
"Now we have some of the most advanced infrastructure on the planet."
After Franco's death in 1975, Spanish leaders overseen by Juan Carlos thrashed out a new political system in a process known as the Transition.
Opposition political parties were legalised and a constitution adopted in 1978, granting new freedoms to Spaniards under a system of parliamentary monarchy.
Following the long dictatorship, Spaniards accepted a "constitutional and democratic form of monarchy", said Luis Palacio Banuelos, a historian at Madrid's King Juan Carlos University.
Divorce was legalised in 1981 and gay marriage in 2005.
RELATED: Spain's King Juan Carlos abdicates
With new freedoms came a cultural boom, symbolised by the so-called "movida" - a new wave of nightlife, music and film centred on Madrid in the 1980s that nurtured the likes of filmmaker Pedro Almodovar.
The economy flourished, particularly after Spain in 1986 joined the EEC, the precursor to the EU, and gained access to its development funds.
As Spain's new democracy matured and Spain transformed itself into the continent's fourth largest economy, the king played a largely figurehead role, travelling the globe as an ambassador.
A threat to the Transition showed its face on February 23, 1981, when soldiers burst into parliament in an attempted coup that Juan Carlos was largely credited with putting down.
"His legitimacy from a popular point of view came from that night, when instead of opting for the coup leaders, he opted for the people," said Bono.
A year later, the Socialist party won a general election, ushering in a period of political stability. It governed until 1996, when it paid the price of an economic crisis and corruption scandals.
The conservative Popular party took over under Jose Maria Aznar, who lowered taxes and privatised a string of big state companies such as the airline, Iberia, and oil driller Repsol.
In 2002, Spain switched currencies from the peseta to the euro.
That gave Spaniards "a strong injection of self-confidence and hope for the future", wrote researchers in the Social Development Review, a specialist journal.
Lower interest rates followed, spurring lending, which in Spain was channelled chiefly to the housing sector.
A decade-long boom helped drive down unemployment to a record low 8.3 percent in 2007.
The boom drew millions of immigrants to the country and "gave an impression of solidity and upward mobility", said Alaminos.
|Spain: Is austerity the answer?
Many Spaniards "could consider themselves upper middle class because they were spending as if they were, but without assets, savings or fixed work."
The boom went bust in 2008, plunging Spain into its latest crisis: a double-dip recession that threw millions out of work.
Many Spaniards started to question the system that had allowed the crisis to happen, their anger fanned by corruption scandals.
"The social and political effects of an economic crisis are devastating," said Fermin Bouza, a sociologist at Madrid's Complutense University.
Mass protests spilled onto Spanish streets in 2011 and 2012, with demonstrators from new pressure groups, organised largely via new online media, demanding reforms of the political system.
The king's failing cast a shadow over his reign, and protesters were already enraged by a corruption scandal implicating his relatives.
Juan Carlos's daughter, Princess Cristina, and her husband, Inaki Urdangarin, are under investigation in a corruption case
"When the veil fell and their obvious problems were exposed, this generated discontent," Alaminos said.
Juan Carlos has melded the trappings of royalty with down-to-earth charm.
At an emotional state funeral for the 191 people killed in the Madrid train bombings of 2004, Juan Carlos and Queen Sofia slowly went row-by-row through Almudena Cathedral, clasping the hands of mourners or kissing them on the cheek.
But his patient work nearly came undone during the financial crisis, with people questioning after the elephant-hunting trip whether a hereditary monarchy was needed.
The WWF's branch in Spain removed Juan Carlos as its honorary president.
Juan Carlos took the unprecedented step of apologising to Spaniards for his actions.
He recently said that he wanted to be remembered as "the king who has united all Spaniards."