[3] Born in Ebesfalva (now Dumbrăveni in Romania) on 3 November 1632, Michael was the son of György Apafi of Apanagyfalva and Borbála Petky.
[8] George II Rákóczi, Prince of Transylvania, invaded the Polish–Lithuanian Commonwealth without seeking the Ottoman sultan's consent in January 1657.
[11] Rákóczi had also entered into correspondence with Count Miklós Zrínyi (or Nikola Zrinski), a prominent aristocrat in Royal Hungary, who offered the Hungarian throne to him against the Habsburg monarch, Leopold I.
[14][16] Polish troops invaded Transylvania and his allies abandoned Rákóczi who was forced to sign a humiliating peace treaty, promising to pay 1,2 million florins as compensation to the Commonwealth on 22 July 1657.
[19] After Rákóczi did not obey the Grand Vizier's summons, Köprülü's Ottoman and Tatar troops invaded Transylvania, destroying Gyulafehérvár (Alba Iulia) and other towns and capturing tens of thousands of prisoners in September.
[28] Kuchuk Ali ordered the delegates of the Three Nations to gather at a meadow near Marosvásárhely (Târgu Mureș) and to acknowledge Apafi's appointment on 14 September 1661.
[28] John Kemény captured Kolozsvár (Cluj-Napoca), but Montecuccoli withdrew most of his troops from Transylvania after learning of Apafi's ascension to the throne on 18 September.
[9][29] Montecuccoli left small German mercenary troops in five Transylvanian strongholds and Apafi vainly requested Leopold I to surrender them.
[29][30] Apafi convened the Diet to Kleinschelken (Șeica Mică) to secure the full legitimization of his rule,[7] because his appointment violated the constitutional principle of the free election of the princes.
[29] Köprülü Mehmed's son, Fazıl Ahmed Pasha, who succeeded his father as grand vizier on 1 November,[29] addressed a letter to Apafi.
[29] The German garrison surrendered Görgény (Gurghiu) to Apafi and the Sublime Porte released part of the sum to be paid by him.
[9] Mehmed IV declared war on the Habsburg Empire in April and charged Fazıl Ahmed with the command of the new military campaign.
[26] The Grand Vizier informed Apafi that he was determined to transform Royal Hungary into a tributary state and ordered him to join the campaign.
[9] Apafi did not dare to resist Fazıl Ahmed's command, but he sent words to the Palatine (or viceroy) of Hungary, Ferenc Wesselényi, about the Ottomans' plans and deferred his departure.
[36] By the time he reached the Grand Vizier's camp at Érsekújvár (Nové Zámky, Slovakia) in October, the Ottomans had already captured the town.
[36] On Fazıl Ahmed's order, Apafi called on the Hungarian nobility to yield to the Ottomans, but his manifesto remained unnoticed.
[36][37] Before leaving Érsekújvár to winter at Belgrade late in October, the Grand Vizier allowed Apafi to return to Transylvania.
[37] Fazıl Ahmed resumed his military campaign against the Habsburg Empire in May,[38] but Montecuccoli inflicted a defeat on the Ottoman troops in the Battle of Saint Gotthard on 1 August 1664.
[26] Despite the victory, Leopold I did not want to risk a lengthy war against the Ottoman Empire and his deputies signed the Peace of Vasvár on 10 August.
[39] The peace treaty confirmed the Ottomans' territorial gains in return for a 22-year truce and Leopold I formally recognized Apafi's rule in Transylvania.
[40] He and the delegates of the Three Nations addressed a letter to Leopold I, pledging that he would never cede the Transylvanian fortresses previously held by German mercenaries to the Ottomans in March 1665.
Following this, Michael opened talks with Leopold and concluded a treaty with the Austrians on 27 September 1687, obtaining their recognition of his authority in Transylvania.