Madrid - Spain set its new king-in-waiting Felipe on the path to the throne on Tuesday after his father's surprise abdication, despite noisy street protests calling for a republic.
A day after King Juan Carlos, 76, declared an end to his four-decade reign, the government sent a law to parliament that will bring the royal handover into force.
Within hours of the king's announcement, crowds shouting and waving the red, yellow and purple Spanish republican flag massed in central Madrid late on Monday, demanding a referendum on the monarchy.
"Tomorrow, Spain will be a republic!" they chanted, brandishing placards reading: "No more kings, a referendum", "A royal transition... without a king".
It was a sign of how times have moved on since Juan Carlos helped guide Spain from dictatorship to democracy in the 1970s.
But the government on Tuesday pushed straight ahead with the constitutional steps needed to pass the crown to 46-year-old Felipe.
Prime Minister Mariano Rajoy gathered his cabinet which approved a draft law to bring into force King Juan Carlos's abdication, the government said in a statement.
The law must now be voted on in parliament, where parties in favour of the monarchy have a wide majority.
The necessary legal steps could be completed by 18 June, parliament speaker Jesus Posada told reporters.
The date of the coronation would be decided by the royal palace in consultation with the government, he added.
The future King Felipe VI on Tuesday made his first public appearance since the abdication news.
He and his father sat side by side in green military uniforms at a pre-scheduled medal ceremony in the sun-splashed grounds of the El Escorial palace near Madrid.
The king, who has had five hip operations in the past few years, walked with the help of a cane but looked relaxed as he spoke occasionally to Felipe.
The prince, a tall former Olympic yachtsman, has higher popularity ratings than his father.
Felipe's accession means Spain will have a new, glamorous queen: his 41-year-old wife Letizia, a former television news presenter.
The couple have avoided being tainted by the scandals dogging the rest of the family.
Many Spaniards were outraged to hear the king took a luxury elephant-hunting trip to Botswana in 2012 as they struggled to find jobs in a recession.
This year his youngest daughter Cristina was named as a suspect in connection with her husband Inaki Urdangarin's allegedly corrupt business dealings.
'Time for a republic'
But also Tuesday three small leftist parties called for a referendum on the monarchy.
Amid rising anger at corruption and hardship, the three -- Podemos, United Left and the Equo green party - together won a fifth of the vote in the European Parliament elections on May 25.
"I think now would be a good time to proclaim a republic," said Paola Torija, a 24-year-old therapist at Monday's demonstration.
"He [the king] had his moment of glory but today it is a bit archaic, a bit useless, an extra cost especially in the crisis we are living in."
Rajoy defended the monarchy, saying a referendum would require a change to the constitution.
The government on Tuesday praised the king's role in Spain's transition to democracy following the death of General Francisco Franco in 1975.
"Without his drive and leadership the transition simply would not have been possible," it said in a statement.
Juan Carlos was widely respected for smoothing Spain's post-Franco transition to democracy, in particular for appearing on national television to thwart an attempted military coup in February 1981.
But in a study by pollster Sigma Dos published in January, support for the king fell to 41 percent while those wanting him to abdicate in favour of Felipe surged to 62 percent.
Only 49% approved of the monarchy itself.
In his abdication address, the king said it was time for "a younger generation" to lead "the transformations and reforms that the current situation demands".
Felipe faces big challenges, not least the corruption scandal engulfing his sister.
The Spanish state also faces pressure from the north-eastern region of Catalonia, which is pushing to hold an independence referendum in November.
The government on Tuesday bet on Felipe as a protector of Spain's political model.
"His training, character, experience and vocation to serve Spain will allow him to carry out his duties suitably in the service of our fatherland and strengthen the parliamentary monarchy," it said.