King Juan Carlos of Spain will abdicate and pass the crown to his son, Crown Prince Felipe. Juan Carlos, once a popular hero for resisting a military coup, was losing ground both in his health and in his standing in Spain.

The announcement came Monday morning from Spanish Prime Minister Mariano Rajoy and then from Juan Carlos himself in a nationwide address.

The king said he is abdicating to make way for his son to become the nation’s next monarch so that a “new generation” can take over. Reuters news agency quoted analysts as saying that the ruling conservative People’s Party was eager to put the more popular Felipe on the throne to try to combat increasingly anti-monarchist sentiment, after small leftist and anti-establishment parties did surprisingly well in last month’s European Parliament election.

The country is just pulling out of a difficult and long recession that has seen faith in politicians, the royal family and other institutions all dwindle.

The king told Spaniards he first started thinking seriously about giving up the throne when he turned 76 in January. He said Monday that the 46-year-old Prince Felipe is ready for the post and will “open a new era of hope combining his acquired experience and the drive of a new generation.”

As the monarchy in Spain has become ceremonial, the move is unlikely to have any immediate major political impact. It does represent a symbolic break for Spain and the close of an important chapter in the nation’s history.

Juan Carlos reigned during a time of profound change in Spain, as it transitioned from a dictatorship under Francisco Franco to a constitutional monarchy and open democracy. And he was a unifying figure in a country divided by regional tensions that spawned, among other things, an often violent Basque separatist movement.

He arrived like something out of a Disney movie and came to embody the hope of an entire nation. Young, handsome, brimming with ideas for the future and equipped with an uncanny ability to win over the common man, Juan Carlos became a paragon of what a constitutional monarch could be. He was hailed internationally as one of the world’s most popular kings and revered locally by the fervent “JuanCarlistas.”

But even his popularity could not surmount Spain’s crippling economic slump, which has saddled the nation since 2008 and left 4.7 million Spaniards unemployed.

The king has weathered years of health issues and bruising royal scandals. His daughter, Infanta Cristina, is a suspect in an ongoing tax fraud and money laundering investigation. Then he broke his hip while hunting elephants in Botswana on a royal expedition that made him seem out of touch with the economic pain many Spaniards were feeling.

The scandals dropped his popularity to a record lows. Recent polls showed that more than six out of 10 Spaniards thought it was time for him to go.

There was nothing ordinary about how Juan Carlos came to power. Born into an exiled royal house residing in Rome, he returned to Spain and soon gained the favor of Franco, Spain’s dictator from 1939 until his death in 1975. Franco nonetheless believed in the monarchy, which had been removed in 1931, and wanted it restored.

In 1969, he designated the 33-year-old Juan Carlos his heir-apparent, conferring upon him the title of Prince of Spain. Juan Carlos, however, ultimately rejected Franco’s authoritarian mantle. When Franco died in November 1975 at age 82, Juan Carlos took steps to modernize and liberalize the nation, steering it toward a parliamentary monarchy.

In 1981, he thwarted an attempted coup when he went on national television and announced that neither he nor the country would abide such behavior. “The Crown cannot tolerate in any form any act which tries to interfere with the constitution which has been approved by the Spanish people,” he said. The confidence he conveyed in his declaration endeared him to many Spaniards who found him honest and strong.

As he stewarded the country toward democracy, he became one of Europe’s most popular royals — and even Spaniards who said they were anti-monarchy conceded they were pro-Juan Carlos. Even as recently as 2011, a poll showed that 76 percent of Spaniards were in favor of the king, as reported in the Whig.

But controversy would soon close in on him. Or, closer to the point, closed in around his family. In 2012, his son-in-law, former professional handball player Inaki Urdangarin, became the first royal in modern European history to face criminal inquiry over embezzled public funds. The investigation later engulfed his daughter as well. 

All the while, Spain itself was sinking into severe economic lows. Lawmakers were pushing through austerity measures, and roughly one-fourth of Spaniards lost their jobs.

In 2012, Juan Carlos decided to take an elephant-hunting trip in Botswana. He had wanted to keep the trip a secret, but word leaked out after he broke his hip and had to be flown home to Spain for hip-replacement surgery. Adding more humiliation to an already humbling fracas, Spain’s World Wildlife Fund kicked out Juan Carlos, who had served as its honorary president since 1968, because it thought his expedition incompatible with its mission.

His health has become a greater issue in recent years. But despite the controversy and the health concerns, he recently said he wanted Spaniards to remember him as “the king who had united all Spaniards.”