On the night of February 23, 1981, Spain teetered on an abyss. An attempted coup d'état threatened to plunge the newly democratic nation, freed only six years earlier from the four-decade tyranny of General Franco, back into dictatorship.
Earlier that afternoon, as the 350 members of the Spanish parliament in Madrid were voting for a new prime minister, 200 armed members of the country's Civil Guard had stormed in and declared a military takeover.
Outside, tanks rolled on the streets; as he held the nation at gunpoint, coup leader General Jaime Milans del Bosch spoke for all the generals who had yet to show their hands when he said he was "awaiting orders" from the king.
But no such orders came.
Instead, King Juan Carlos, head of state, went on TV and radio to demand the support of the armed forces. He had, he told his fellow Spaniards that night, "firmly rejected the actions carried out this afternoon in Parliament".
The coup collapsed and the recently crowned king won the hearts of the nation.
"The King's actions that night," reported Time magazine, "not only helped the fledgling democracy survive its first serious crisis but also secured the reputation of the monarchy for decades to come."
This was the scale of the affection amassed by the king which, in his 75th year, he now appears to be in danger of squandering.
This week, a poll carried out for El Pais newspaper found that the 75-year-old king's popularity had slumped to an all-time low, down 33 points in just three months, from plus 21 in December to minus 11. With 53 per cent of respondents disapproving of the king, it is the first time his ratings have ever slipped into negative figures.
Today, as he wrestles with a crisis of popularity that threatens to set the tone for his legacy, the King could be forgiven for harking back to the carefree days before he became head of state, at the age of 38.
When he was crowned King of Spain in 1975, he owed his accession to the throne not to divine right but to the blessing of General Francisco Franco, a fascist dictator who had risen to power with the support of Nazi Germany.
Juan Carlos Alfonso Víctor María de Borbón y Borbón-Dos Sicilias was born in exile in Rome in 1938. Spain's last monarch, his grandfather, Alfonso XIII, had ruled from 1886 until he was deposed in 1931 by the Second Spanish Republic and fled with the royal family to Italy.
At the outbreak of the Spanish Civil War in July 1936, Alfonso backed General Franco's military uprising. He event sent his son Juan, the Count of Barcelona, to take part. However, the designated heir to the throne was turned back at the border, and Franco made clear that the Nationalists would accept neither Alfonso nor his son as king.
Franco ordered three days of mourning when Alfonso died in 1941, but it was 1969 before the increasingly frail dictator declared that it would be the former king's grandson, Juan Carlos, who would eventually be king and Franco's successor as head of state.
The intervening years gave Juan Carlos plenty of time to prepare for the role. In a 1971 article, Time magazine noted that the prince, "a handsome, blond 33-year-old married to Princess Sofia of Greece, now stumps the country and makes trips abroad to build up a political image that can fill the Franco void and the gap in the Spanish monarchy".
The king-in-waiting, added the magazine, was "an avid yachtsman, golfer and hunter ... a brown belt judo man and a licensed pilot, commuting by helicopter from his home at Zarzuela Palace outside Madrid".
In fact, the future king did not see his country for the first time until 1948, when Franco allowed the ten-year-old to be educated in Spain, first at the San Isidro Institute in Madrid and later at the military academies of the army, navy and air force. Between 1960 and 1961 he studied law, economics and taxation at Madrid's Complutense University.
In 1962, he married Princess Sofia, the eldest daughter of King Paul I and Queen Federica of Greece. But it would be November 22 1975, two days after Franco's death at the age of 83, before Juan Carlos was proclaimed king.
"In his first message to the nation in the Spanish Parliament," records his biography, "he expressed the basic ideas of his reign - to restore democracy and to become the King of all Spaniards, without exception".
It was a call to unity, and the transition to democracy began with the 1976 Law for Political Reform. The next year, Spaniards voted in their first democratic elections since 1936. In 1978, a constitution was approved by a referendum and established a constitutional monarchy.
The strength of the constitutional monarchy has been reflected in the fact that the king has remained a popular head of state during various governments. In 2005, a poll in El Mundo showed that 78 per cent of Spaniards still thought the king was "good or very good" and as recently as 2006, he remained impervious to scandal. That year, he was accused of having shot a tame, inebriated bear during a hunting trip to Russia. The claim was "ridiculous", according to a palace spokesman.
The following year at a summit of Ibero-American leaders in Chile, Venezuela's Hugo Chávez had started attacking a former Spanish prime minister as a fascist, when the king shouted at Chavez to "just shut up" before storming out. The incident played well in Spain, where the outburst became a popular mobile phone ringtone and the media hailed the king for defending the country's honour.
But he had crossed an invisible line. The king had strayed into politics. It was shortly after that that the first cracks in Spain's royal romance began to appear.
That same year, a Spanish magazine published a caricature of the king's son, Prince Felipe, making love to his wife, saying: "If you get pregnant, that will be the closest to real work I have ever done in my life".
The authors were fined €3,000 each (Dh14,434) but the damage was done. Later that year, much was made of the split of the king's daughter, Elena, from her husband.
Some trace the true beginning of the decline in support to 2008 when, on the eve of her 70th birthday, his wife came out from behind her image as a kindly, uncontroversial queen to reveal her staunch, right-wing views on topics such as homosexuality and euthanasia.
Worse, in a biography, The Queen Up Close, Queen Sofia also questioned several political decisions that had been made.
The monarchy, cautioned El Pais, was losing support among young people, who had not witnessed Juan Carlos's defence of democracy in 1981. The royal family began to come under increasingly close examination - and never more so than today, as a high-profile corruption case threatens to engulf them.
Iñaki Urdangarin, the Duke of Palma de Mallorca and husband of the king's daughter, Princess Cristina, is being investigated over allegations that he charged officials inflated prices for staging tourism and sporting events. Now the royal family faces an uneasy first, as Cristina has been subpoenaed over the embezzlement case.
The king's own lifestyle has also come under the microscope and, in a nation facing 26 per cent unemployment, he has been accused of hypocrisy.
"We all have to tighten our belts a bit because of the difficult times for the economy," he said. Later, it emerged that public spending on the monarchy had been cut by just 2 per cent. Worse, the king was found to have been on a Dh150,000 safari to Botswana, where he had been shooting elephants - much to the disgust of the World Wildlife Fund, which sacked him as the head of the organisation in Spain.
Last year, the royal household launched a PR offensive, with a new website that was "part of an effort to improve communications between the Crown and all Spaniards". Judging by the polls, it has not worked.
For some critics, the status of the king in the hearts of the Spanish people has been a convenient illusion in a nation divided over the Franco years. In the harsh light of the realities of the modern world that illusion is now under siege.
Last month, it took Germany's magazine Der Spiegel to say what many in Spain are now thinking.
"King Juan Carlos had an understanding with his people: He would be regal and they would respect him. But now that he has broken his end of the bargain, Spaniards are quickly jettisoning theirs. Is it time to dissolve the Spanish monarchy?"
January 5, 1938 Born the son of Juan de Borbon y Battenberg, head of the royal household, and Maria de las Mercedes de Borbon y Orleans
1948 Moves to Spain with Franco's approval to continue education
1956 Younger brother Alfonso dies in an accident
1962 Marries Princess Sofia of Greece
1963 Daughter Elena born, followed by Cristina in 1965 and son Felipe in 1968
1969 Designated Spain's future king by Franco
1972 Comes 15th in his sailing event at the Munich Olympics
1975 Becomes king
1978 Confirmed as constitutional monarch
1981 Faces down military coup
2010 Has operation to remove tumour from lung
2013 Royal family quizzed by police in corruption case