A tearful King Juan Carlos sealed his abdication of the Spanish crown on Wednesday after a four-decade reign, leaving the throne to his 46-year-old son, Felipe VI.
The 76-year-old monarch signed the act of parliament ending his reign with a green and gold pen at a ceremony in Madrid's Royal Palace, then hugged his son, who will be sworn in Thursday morning.
The embrace between the scandal-hit king and his heir under the palace's chandeliers marked the first royal succession in Spain's modern democratic history.
Dressed in a dark blue suit and pink tie, Juan Carlos, who uses a cane following several hip operations, stood unaided for part of the ceremony but briefly held Felipe's arm to steady himself.
A band struck up the national anthem as Felipe, his wife and future queen Letizia and Juan Carlos's wife Queen Sofia, applauded the abdicating king.
Juan Carlos is credited with helping guide Spain to democracy after the death of the dictator Francisco Franco in 1975, but his popularity was damaged by scandals in recent years.
Now Felipe is tasked with cleaning up the monarchy's image and soothing a country stricken by recession. Some are calling on him to unify Spain as the Catalonia region seeks independence.
Madrid was decked with red and yellow Spanish flags and white flowers for the soon-to-be King Felipe VI. Shops were selling T-shirts and fridge magnets with the faces of the new king and queen.
Workers hoisted a great red canopy with the state coat of arms embroidered in gold over the front doors of the lower house of parliament in central Madrid.
Felipe will pass through them, dressed in a blue military uniform with the red silk sash of the forces' commander in chief, to be sworn in by the parliament on Thursday morning.
"There's a festive atmosphere. It's a party for this new king," said one passerby, Carlos Tesorero.
"All the Spanish people have faith in him. He is very capable and I think he will be a good king."
The Spanish flag fluttered from balconies across Madrid and two giant ones hung down the facade of the city hall.
"It looks more like a football match. Lots of flags. Too much, perhaps," said Jose Manuel Garrucho, a 20-year-old student, outside the parliament.
By coincidence, Wednesday was also a big night for Spain's national football team, with a crucial World Cup tie against Chile.
Felipe, a blue-eyed former Olympic yachtsman who stands six and a half feet tall, legally becomes king at midnight Wednesday when his father's abdication takes effect, government officials say.
He and the elegant 41-year-old wife, Letizia, a former television anchorwoman, have two daughters, seven-year-old Sofia and eight-year-old Leonor, who will become the youngest direct heir to a throne in Europe.
The new king is to be proclaimed after swearing to uphold the constitution and delivering a speech to parliament.
He and Letizia will then be driven through Madrid's streets and appear before the crowds on the front balcony of the Royal Palace.
Felipe faces a daunting task to clean up the image of the monarchy, which was restored when Juan Carlos took the throne in 1975 after Franco's death.
Juan Carlos outraged Spaniards in 2012 by going on a luxurious African elephant-hunting safari during a recession.
Felipe's 49-year-old sister Cristina, who risks being put on trial for alleged tax fraud, is not invited to the succession party.
Many Spaniards are demanding the right to vote on whether to have a king at all.
Protesters are planning a demonstration in central Madrid on the day of the enthronement, defying a ban by authorities.