She was thirteen, and he was her uncle. Mariana was meant to marry the king's son. Instead, she married the king.

On 8 November 1648, in the imperial palace in Vienna, Mariana of Austria married Philip IV of Spain by proxy. Philip was not there. Her brother Ferdinand, already King of Hungary and Bohemia, represented him at the ceremony. A girl went to the altar with her brother to marry their uncle, a man nearly thirty years older than herself.

The family connections were close long before this wedding. Mariana's father was the Holy Roman Emperor Ferdinand III. Her mother, Maria Anna, had been a Spanish infanta, the sister of Philip IV, who had left Madrid to marry into the Austrian branch of the family. The plan for her daughter was to send her back the other way, as the bride of Philip's son and heir, Baltasar Carlos. He was Mariana's first cousin. A marriage between them would have joined the Austrian and Spanish Habsburgs once again.

In May 1646, when Mariana was eleven, her mother died in Linz during a pregnancy. Within months there was another death. On 9 October, Baltasar Carlos died in Zaragoza, eight days before his seventeenth birthday. The marriage planned for him could no longer take place.

For his father, this was the loss of a son and of his only surviving legitimate male heir. Philip had already lost his first wife, Isabel of Bourbon, in 1644. His daughter Maria Teresa was still alive, but the search for another wife was now bound up with the search for another son. The girl intended to become his daughter-in-law became a candidate to replace his dead wife.

Mariana had not yet reached her twelfth birthday when the prince died. Philip was forty-one.

The negotiations continued into 1647, and an agreement was reached for the king to marry his niece. The Austrian and Spanish branches would still be joined; Mariana would still go to Spain. What had changed was the generation of the man she would marry. Her mother's brother would become her husband. The family could accommodate the rearrangement. The bride would have to live it.

A portrait painted around this time by Frans Luycks, court painter in Vienna, shows her standing full length beneath a red curtain, one hand resting on a table beside a vase of flowers, the other holding a fan. Her clothes, the formal pose and the curtain give her the appearance expected of a princess. The figure inside them was still a child. Portraits like this travelled between the courts, keeping relatives informed and helping marriage negotiations along. A royal daughter could be presented to a distant court long before she arrived there herself.

By November 1648, Mariana was thirteen. Philip was forty-three. The wedding took place in the great hall of the palace in the afternoon, before members of the imperial court, ambassadors and knights of the Golden Fleece. Mariana wore Spanish dress. Before she had travelled to her husband's country, she was already appearing in its clothes.

The emperor's choir and musicians opened the ceremony. The Count of Lumiares handed Philip's written authority to Ferdinand, who passed it through another court official to the secretary to be read aloud. That document allowed a brother to take the bridegroom's place. Cardinal Harrach then ordered the reading of the papal dispensation. The Church's permission for a niece to marry her uncle was part of the public proceedings, heard before anyone went to the altar.

Ferdinand and the cardinal accompanied Mariana there. Harrach performed the marriage and blessed the spouses, one present and one absent. Every part of the king's absence had been provided for: an authorised representative, a document setting out his powers, and a dispensation permitting the union. A king could marry without entering the room.

Mariana had to be there.

The ceremony made her Philip's wife, but it did not bring her to Spain. The journey still lay ahead, and so did another ceremony in her husband's presence. The marriage documents carried the names of two rulers and their families; the person who had to make that journey was a thirteen-year-old girl.

On 7 October 1649, at Navalcarnero, near Madrid, Mariana and Philip received the marriage blessing together in the oratory of the Casa de la Cadena. Almost eleven months had passed since the ceremony in Vienna. The brother who had represented the bridegroom was no longer beside her. The man present now was the father of the prince she had originally been intended to marry. Philip was forty-four. Mariana was fourteen.