Madrid:
A teary-eyed King Juan Carlos sealed his abdication of the Spanish crown on Wednesday after a four-decade reign, clearing the throne for his 46-year-old son, Felipe VI.
The 76-year-old monarch signed the act of parliament ending his reign with a golden pen at a ceremony in Madrid's Royal Palace, then hugged his son, who will be sworn in on Thursday morning.
The embrace between the elderly king and his heir under the palace's chandeliers marked the first royal succession in Spain's post-Franco history.
Dressed in a dark blue suit and pink tie, Juan Carlos, who uses a cane following repeated hip operations, stood unaided during part of the ceremony but had to briefly hold Felipe's arm to steady himself.
A band struck up the national anthem as Felipe in a dark suit, his wife and future queen Letizia in a black top and white skirt, and Juan Carlos's wife Queen Sofia, applauded the abdicating king.
Minutes earlier, cannons had fired a salute and shouts of "Long Live the King!" rang out as the royals arrived by car at the old palace in western Madrid.
Juan Carlos is credited with helping guide Spain to democracy after the death of the dictator Francisco Franco, but his popularity was damaged by scandals in recent years.
- Flowers, flags for new king -
Madrid was bedecked with flags to hail the soon-to-be Felipe VI.
Red and white flowers -- nearly 16,000 blooms, according to the City Hall -- adorned the streets.
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 red-and-yellow Spanish flag fluttered from balconies across Madrid and two giant flags 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.
- Daunting task -
Felipe, a blue-eyed former Olympic yachtsman who stands 1.98 metres (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 former television news reader have two blonde-haired 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 risks being put on trial for alleged tax fraud. She is not invited to the succession party.
Beyond surmounting his own family's woes, Spaniards will look to Felipe to inspire them as they grapple with a 26 percent unemployment rate.
He is also called on to work for national unity as the northeastern region of Catalonia seeks an independence referendum on November 9.