Princess Leonor, the heir apparent to the Spanish throne, swore allegiance to the constitution on Tuesday, her eighteenth birthday, as a legal first step towards taking over her father King Felipe VI's throne.
Her mother Queen Letizia and younger sister Sofia joined Felipe as Leonor took the oath before a joint session of both houses of parliament.
Leonor wore a white suit and after the playing of the national anthem, she pledged loyalty on the same copy of the constitution as her father did 37 years ago.
"I swear to faithfully fulfill my duties, to protect and have protected the Constitution and its laws, to respect the rights of citizens and autonomous communities and to be faithful to the king," she said.
Loud applause echoed around the chamber of deputies in Madrid for several minutes and the king embraced his daughter.
Madrid City Hall set up giant screens in the central Puerta del Sol square for the public to watch a live broadcast of the brief ceremony.
A crowd had gathered outside parliament amid a sea of Spanish flags and shouts of "Long live Spain".
The streets had been decorated with images of the queen-in-waiting.
With the oath taken, Leonor can legally succeed Felipe and automatically becomes head of state in the event of the monarch's absence.
Her grandfather Juan Carlos, who took the oath in 1969 when dictator General Francisco Franco named him as his successor, did not attend the ceremony.
Media reported he would attend a private party at the El Pardo palace near Madrid after the event, the first formal royal family gathering he would attend since going into exile.
Juan Carlos came to the throne in 1975 after Franco's death and was widely respected for his role in helping guide Spain from dictatorship to democracy.
But a steady flow of embarrassing stories about his love life and personal wealth eroded his standing.
He abdicated in 2014, dogged by scandals and health problems, and in 2020 went into self-imposed exile in Abu Dhabi amid investigations into his financial affairs, since been shelved.