According to the terms set at the
First Congress of Vienna in 1515, Ferdinand married
Anne Jagiellonica, daughter of King
Vladislaus II of Hungary and Bohemia on 22 July. The
Kingdom of Hungary and
Kingdom of Bohemia were both
elective monarchies, where the parliaments had the sovereign right to choose the king. When his brother-in-law
Louis II of Hungary and Bohemia was killed at the
Battle of Mohács against the
Ottoman Empire on 29 August 1526, Ferdinand immediately declared himself a candidate in the royal elections. On 24 October 1526, the
Bohemian Diet, acting under the influence of chancellor
Adam of Hradce, elected Ferdinand king of Bohemia under conditions of confirming traditional privileges of the estates and also moving the Habsburg court to
Prague. The success was only partial, as the Diet refused to recognise Ferdinand as hereditary ruler of the kingdom. The throne of Hungary was disputed between Ferdinand and
John Zápolya,
Voivode of Transylvania. They were supported by different factions of the Hungarian nobility. Ferdinand also had the support of his brother, Emperor
Charles V.
Nicolaus Olahus, secretary of Louis, attached himself to Ferdinand's part, but retained his position with his sister, Queen Dowager
Mary. On 10 November 1526, in
Székesfehérvár, John Zápolya was proclaimed king by a
Hungarian Diet formed of the untitled lesser nobility (gentry). On 17 December 1526, in
Pozsony (
Bratislava in Slovak), Ferdinand was elected
King of Hungary, Dalmatia, Croatia, Slavonia, etc. by a rump Diet the higher aristocracy (the magnates or barons) and the Hungarian Catholic clergy. Accordingly, Ferdinand was crowned as King of Hungary in the
Székesfehérvár Basilica on 3 November 1527. The Croatian nobles unanimously accepted the Pozsony election of Ferdinand I, receiving him as their king in the
1527 election in Cetin, and confirming the succession to him and his heirs. In return for the throne, King Ferdinand promised to respect the historic rights, freedoms, laws, and customs of the Croats when they united with the Hungarian kingdom and to defend Croatia from Ottoman invasion. The Austrian lands were in miserable economic and financial conditions, but Ferdinand was forced to introduce the so-called Turk Tax (
Türkensteuer) for the war against the Ottomans. In spite of huge Austrian sacrifices, he could not raise enough money. His annual revenues only allowed him to hire 5,000 mercenaries for two months. So Ferdinand asked for help from his brother the Emperor Charles V, and borrowed from bankers like the
Fugger family. Ferdinand
defeated Zápolya at the
Battle of Tarcal in September 1527 and again in the
Battle of Szina in March 1528. Zápolya fled the country and applied to Sultan
Suleiman the Magnificent for support. This led to the most dangerous moment of Ferdinand's career, in 1529, when Suleiman
took advantage of this Hungarian support for a massive but ultimately unsuccessful assault on Ferdinand's capital: the
Siege of Vienna, which sent Ferdinand to refuge in Bohemia. A further Ottoman invasion was repelled in 1532 (see
Siege of Güns). Ferdinand then made peace with the Ottomans. The
Treaty of Constantinople (1533) divided Hungary between the Habsburg kingdom in the west, and John Zápolya's
Eastern Hungarian Kingdom, a vassal state of the Ottoman Empire. Together with the formation of the
Schmalkaldic League in 1531, this struggle with the Ottomans caused Ferdinand to grant the
Nuremberg Religious Peace. As long as he hoped for a favorable response from his humiliating overtures to Suleiman, Ferdinand was not inclined to grant the peace which the
Protestants demanded at the
Diet of Regensburg which met in April 1532. However, as the army of Suleiman drew nearer, he yielded. On 23 July 1532, the peace was concluded at
Nuremberg where the final deliberations took place. Those who had up to this time joined the Reformation obtained religious liberty until the meeting of a council, and in a separate compact all proceedings in matters of religion pending before the imperial chamber court were temporarily paused. In 1538, in the
Treaty of Nagyvárad, Ferdinand induced the childless Zápolya to name him as his successor. But in 1540, just before his death, Zápolya had a son,
John II Sigismund, who was promptly elected king by the Diet. Ferdinand invaded Hungary, but the regent, Frater
George Martinuzzi,
Bishop of Várad, called on the Ottomans for protection. Suleiman marched into Hungary (see
Siege of Buda (1541)) and not only drove Ferdinand out of central Hungary, he forced Ferdinand to agree to pay tribute for his lands in western Hungary. , 1664) John II Sigismund was also supported by is mother's father,
Sigismund I,
King of Poland and
Grand Duke of Lithuania. But in 1543 Sigismund made a treaty with the Habsburgs and Poland became neutral; his son
Sigismund Augustus married Ferdinand's daughter Archduchess
Elisabeth of Austria. The Eastern Hungarian Kingdom was ruled by John II Sigismund's mother
Isabella Jagiellon as regent, with Bishop Martinuzzi as the real power. But Isabella's hostile intrigues and threats from the Ottomans led Martinuzzi to switch round. In 1549, he agreed to support Ferdinand's claim, and Imperial armies marched into Transylvania. In the
Treaty of Weissenburg (1551), Isabella agreed on behalf of John II Sigismund to abdicate as king of Hungary and to hand over the
Holy Crown of Hungary and regalia. Thus Ferdinand acquired
Royal Hungary and Transylvania; he recognised John II Sigismund as vassal Prince of Transylvania and betrothed one of his daughters to him. Meanwhile, Martinuzzi attempted to keep the Ottomans happy even after they responded by sending troops. Ferdinand's general Castaldo suspected Martinuzzi of treason and with Ferdinand's approval had him killed. Since Martinuzzi was by this time an
archbishop and
Cardinal, this was a shocking act, and
Pope Julius III excommunicated Castaldo and Ferdinand. Ferdinand sent the Pope a long accusation of treason against Martinuzzi in 87 articles, supported by 116 witnesses. The Pope exonerated Ferdinand and lifted the excommunications in 1555. From 1548 to the end of the war, a
Habsburg Spanish infantry tercio that had fought in the
Schmalkaldic War was detached in Hungary to fight against John Zápolya's supporters on behalf of Ferdinand. Emperor Charles V sent Spanish troops to help his brother regularly from 1527 to 1553. in 1552 The
war in Hungary continued. In the
Ottoman campaign of 1552, two Ottoman armies took the eastern part of central Hungary. In 1554, Ferdinand sent
Ogier Ghiselin de Busbecq to
Constantinople to discuss a border treaty with Suleiman, but he could achieve nothing. In 1556, the Diet returned John II Sigismund to the eastern Hungarian throne, where he remained until 1570. De Busbecq returned to Constantinople in 1556, and succeeded on his second try. The Austrian Habsburgs needed the economic power of Hungary for the Ottoman wars. During the Ottoman wars the territory of the former
Kingdom of Hungary shrank by around seventy percent. Despite these enormous territorial and demographic losses, the smaller, heavily war-torn Royal Hungary had remained economically more important to the Habsburg rulers than Austria or Kingdom of Bohemia even at the end of the 16th century. Out of all his countries, the depleted Kingdom of Hungary was, at that time, Ferdinand's largest source of revenue.{{cite web |title=The Financial Administrative Reforms and Revenues of Ferdinand I in Hungary (English summary) |author=Kenyeres, István ==Consolidation of power in Bohemia==