Ferdinand was born in Graz, Archduchy of Austria, Holy Roman Empire on 9 July 1578, the son of Charles II, Archduke of Austria and Maria Anna of Bavaria. Ferdinand belonged to the prestigious House of Habsburg, and he attended the University of Ingolstadt until 1595. In 1617, Ferdinand was elected King of Bohemia, and the Catholic Ferdinand became a bitter rival of the Protestant Bohemian Estates. In 1618, a revolt against his rule broke out in Bohemia; that same year, he became King of Hungary, and he became Holy Roman Emperor upon the death of Emperor Matthias in 1619. Ferdinand smashed the Bohemian revolt in 1620 with the help of Count Tilly and Albrecht von Wallenstein, the latter of whom recruited his own mercenary army to fight for the financially-strained Holy Roman Empire in exchange for the right to plunder. In 1632, Count Tilly was killed in battle with Sweden, and Wallenstein was assassinated in 1634 after he became a threat to the empire. Ferdinand succeeded in signing a peace treaty with Sweden and several small German states in 1635 after defeating them in battle, but France entered the war that same year. Ferdinand died in Vienna in 1637 at the age of 58, and his son Ferdinand III of Germany succeeded him.