Born in Vienna on 8 September 1633, and baptised as Ferdinand Franz, Ferdinand IV was the eldest son of Ferdinand III, Holy Roman Emperor and his first wife Maria Anna, the daughter of Philip III of Spain. At a young age, Ferdinand IV took his father's role as Archduke of Austria. In 1646, Ferdinand IV became King of Bohemia as he shared the role with his father Emperor Ferdinand III. He was crowned on 5 August 1646, and also shared the role of Duke of Cieszyn with Ferdinand III. Ferdinand IV also shared the role as King of Hungary and Croatia with his father; his coronation took place on 16 June 1647 in Pressburg, present-day Slovakia.
After the French attempted to modify the system of the election of King of the Romans, Emperor Ferdinand III made an opportunity of a recent decline in the prestige of France, and was able to install Ferdinand IV as King of the Romans, and de facto heir to the Holy Roman Empire. He was crowned in Ratisbon (Regensburg, present-day south-east Germany) on 18 June 1653 after gaining the position on 31 May 1653. However, Ferdinand IV unexpectedly died of smallpox in Vienna on 9 July 1654, and was later succeeded by his brother Leopold I as King of the Romans. Prior to his death, it was planned that he would marry Philip IV of Spain's daughter Maria Theresa of Spain, his cousin. Upon the death of Ferdinand III, Leopold I was elected as Holy Roman Emperor.