Born Maria Madalena Josefa Teresa Bárbara, Barbara was the eldest child and only daughter of King John V of Portugal and Archduchess Maria Anna of Austria, a daughter of Emperor Leopold I. She was baptised "Maria Madalena Bárbara Xavier Leonor Teresa Antónia Josefa", her names honouring a number of saints and relatives. She was usually referred to as "Bárbara" or "Maria Bárbara", a name never before used among Portuguese royalty but given in honour of Saint Barbara, the saint of her birthday. She was a first cousin of the future Empress Maria Theresa as well as Maria Josepha of Austria. Although her parents were married in 1708, they remained childless for nearly three years. The King then made a promise to God that if an heir to the throne was born, a great convent would be built as a sign of gratitude. On 4 December 1711 Barbara was born, and, as promised, the King had the Convent of Mafra built.