After Sultan
Suleiman the Magnificent defeated Ferdinand's brother-in-law
Louis II, King of
Bohemia and of
Hungary, at the
battle of Mohács on
29 August 1526, Ferdinand was elected King of Bohemia in his place. The
throne of Hungary became the subject of a dynastic dispute between Ferdinand and
John Zápolya, voivode of
Transylvania. Each was supported by different factions of the nobility in the Hungarian kingdom; Ferdinand also had the support of Charles V. After defeat by Ferdinand at the
Battle of Tokaj in 1527, Zápolya gained the support of
Suleiman. Ferdinand was able to win control only of western Hungary because Zápolya clung to the east and the Ottomans to the conquered south. Zápolya's widow,
Isabella Jagiełło, ceded
Royal Hungary and Transylvania to Ferdinand in the
Treaty of Weissenburg of 1551. In 1554
Ogier Ghiselin de Busbecq was sent to
Istanbul by Ferdinand to discuss a border treaty over disputed land with Suleiman.
The most dangerous moment of Ferdinand's career came in 1529 when he took refuge in Bohemia from a massive but ultimately unsuccessful assault on his capital by Suleiman and the Ottoman armies at the
Siege of Vienna. A further Ottoman attack on
Vienna was repelled in 1533. In that year Ferdinand signed a peace treaty with the
Ottoman Empire, splitting the Kingdom of Hungary into a Habsburg sector in the west and John Zápolya's domain in the east, the latter effectively a vassal state of the Ottoman Empire.
In 1538, by the
Treaty of Nagyvárad, Ferdinand became Zápolya's successor. He was unable to enforce this agreement during his lifetime because
John II Sigismund Zápolya, infant son of John Zápolya and Isabella Jagiełło, was elected King of Hungary in 1540. Zápolya was initially supported by King
Sigismund of
Poland, his mother's father, but in 1543 a treaty was signed between the Habsburgs and the Polish ruler as a result of which Poland became neutral in the conflict. Prince
Sigismund Augustus married
Elisabeth of Austria, Ferdinand's daughter.