Spain's ex-king oversaw the transition from dictatorship to democracy but in later years became tainted by scandals that damaged the monarchy.
The exile of Spain's former King Juan Carlos I amid new corruption allegations is a shock to the country where he reigned for almost four decades having played a pivotal role in the transition from dictatorship to democracy.
Juan Carlos was groomed by General Francisco Franco as his successor.
But instead of continuing the sort of authoritarian system Spain had known under the dictator, the new king quickly brought in reforms, dismantling the old regime and enabling the country to develop under a constitutional monarchy.
For decades he was extremely popular but in later years became tainted by scandals that increasingly damaged the Spanish monarchy's reputation.
Here are some of the key events illustrating the impact the ex-king has had in Spain, from his coronation in the 1970s to the announcement on Monday of his decision to leave the country.
Juan Carlos was crowned King of Spain on November 22, two days after the death of General Franco who had ruled the country since his forces won the 1936-39 Spanish Civil War.
The grandson of the last king before the monarchy was abolished in 1931, he had been chosen by the dictator to continue his legacy.
As Prince of Spain, Juan Carlos had been obliged to swear loyalty to Franco's movement, and often appeared alongside the general, praising his record.
However, unbeknown to the ageing leader towards the end of his rule, the prince met secretly with opposition leaders and exiles, and once king, he moved quickly to introduce reform.
1976 — 1978
Juan Carlos dismissed Spain's Francoist prime minister in July 1976 and replaced him with the little-known politician and lawyer Adolfo Suarez.
The following months saw the legalisation of previously-banned political parties, including the Socialists and Communists, despite strong opposition from the right-wing military. The process saw the political left recognise the monarchy.
In May 1977 Juan Carlos' father, viewed by many monarchists as the legitimate king, renounced his claim. The following month Spain held its first democratic general election since 1936. A high turnout saw Suarez's centrist movement emerge as the largest party.
A new Spanish Constitution re-establishing a constitutional monarchy was passed by the country's new parliament and approved by a referendum in 1978.
This period also brought an Amnesty Law which saw political prisoners freed but controversially granted impunity to the perpetrators of crimes during the Civil War and Franco's subsequent reign.
The military's ongoing influence was illustrated by an attempted coup d'état on February 23. Two hundred Civil Guard officers led by a lieutenant-colonel burst into the parliament's lower chamber and held deputies and ministers hostage for 18 hours.
King Juan Carlos played a crucial role in defusing the situation, denouncing the coup attempt on television and calling for the democratic transition to continue. Although shots were fired, no-one was killed and the hostage-takers surrendered.
1982 — 2012
The monarch's active involvement in Spanish politics effectively ended with the 1982 election, which brought the Socialists to power. Spain went on to join what was then the European Community in 1986.
Although his role was largely ceremonial, Juan Carlos was seen as an authoritative figure symbolising the country's unity. By the mid-2000s the king had an approval rate of more than three-quarters of Spaniards.
In 2007 at an Ibero-American summit he famously put down a ranting Venezuelan President Hugo Chavez with the phrase "Why don't you shut up?".
2012 — 2020
An ill-judged elephant-hunting trip to Botswana in April 2012 brought strong criticism for Juan Carlos. Although it was not paid for by the taxpayer, it came at a time of economic crisis in Spain which saw soaring unemployment, especially among the young. The king later apologised.
However, his role also came into question in the early part of the decade amid an embezzlement scandal involving his daughter Cristina and her husband. At the trial in 2017 she was cleared but Inaki Urdangarin was jailed, a sentence confirmed on appeal.
On June 2, 2014, Juan Carlos made a televised address confirming that he would abdicate in favour of his son, the Prince of Asturias, who became crowned King Felipe VI on June 19.
His image was further damaged in 2018 when details emerged of an alleged mistress and financial irregularities. The ex-king announced he was retiring from official duties in June 2019.
After growing calls for an investigation into alleged corruption, the royal family said it would renounce any inheritance from Juan Carlos in March 2020.
In June the Supreme Court announced an inquiry into the ex-king's alleged business dealings with Saudi Arabia. On August 3 following further allegations Juan Carlos said he was leaving the country.