King Juan Carlos, who abdicated on Monday aged 76, led Spain to democracy after decades of dictatorship and foiled a military coup, winning widespread respect that later crumbled away in the face of royal scandals.
Juan Carlos played a determining role in Spanish modern history when he stepped up as the first crowned head of state in 44 years after the death of General Francisco Franco.
He took the throne within days of Franco's death in November 1975, having been named successor by the dictator himself, who passed over Juan Carlos's father, Juan de Borbon.
"My father always said... that his ambition was to become the king of all the Spanish and I am very proud to have made the dream of my father an undeniable reality," Juan Carlos said in his only authorised biography, published in 1993.
As Franco's appointed successor, Juan Carlos had reportedly been pelted with fruit when travelling around Spain during the dictatorship, but once crowned, his easy-going manner endeared him to many Spaniards.
He also showed grit when most needed.
He defied the hopes of the Francoists for an extension of autocratic rule. Instead, he oversaw the creation of a new system of parliamentary monarchy, with a new constitution that was approved by referendum in 1978.
Juan Carlos was credited with helping defuse an attempted coup in February 1981 by soldiers who stormed into parliament shooting and who held lawmakers hostage for several hours.
The king's appearance on television urging support for the democratic government was instrumental in blocking the attempt.
"I knew that the soldiers were going to agree because I had been named by Franco," the king said later, adding that he knew most of the officers from his days in the military academy, and he was their commander in chief.
After the Madrid train bombings in March 2004, Juan Carlos and his wife Queen Sofia threw protocol aside at a memorial service when they comforted the families of some of the 191 people killed.
But the king's image later suffered from scandal.
One of the most damaging was a corruption investigation targeting his youngest daughter Cristina's husband, former Olympic handball player Inaki Urdangarin, that erupted in 2011.
Urdangarin has appeared in court but denies any wrongdoing.
Cristina was linked to Urdangarin's business affairs and she was herself declared a suspect in January 2014 over related allegations of tax fraud and money laundering.
Under closed-door questioning by the investigating judge in February she denied knowledge of her husband's business dealings.
The taint of corruption over the royal family outraged many Spaniards suffering from an economic slump, austerity policies and towering unemployment.
A keen sportsman, Juan Carlos was long known for his fondness for hunting.
In 1956, Juan Carlos, 18 at the time, witnessed his own brother Alfonso being shot and killed in an accident. The brothers were reportedly playing with a gun at the time.
In 2012, many Spaniards were angered to learn that the king had taken a luxury elephant hunting trip to Botswana, seen as an unacceptable extravagance during a recession.
The Botswana trip, which came to light only because he broke his right hip and was flown home for surgery, undermined earlier declarations that he lost sleep thinking about unemployed young people.
Amid signs that public opinion for the monarchy was slipping in the economic crisis, the king apologised publicly for the trip as he emerged from hospital on crutches.
His medical problems raised further questions over his reign.
Between May 2010 and November 2013, he had surgery nine times: on a benign lump in his lung, his right knee, an Achilles tendon, a slipped disc, two operations on his right hip and three on his left.
In a poll published in January 2014 by centre-right newspaper El Mundo, the number of people with a high or very high opinion of the king fell nine percentage points over 2013 to 41 percent.
The number of people wanting him to abdicate in favour of his son Prince Felipe, 46, surged by 17 percentage points to 62 percent, according to the survey by pollster Sigma Dos.
Felipe, who will now be crowned as Juan Carlos's successor, has two older sisters, but Spain maintains the right of the first-born son to inherit the throne.
After the elephant hunting affair, experts warned that respect for Juan Carlos did not mean unquestioning support for the crown.
"The king has prestige and authority for being the driver of the political transition," said Antonio Torres del Moral, a monarchy specialist, in April 2012.
"In Spain, people are more 'Juan-Carlist' than monarchist."