Before emerging in politics and military, Imre Thokoly commenced with his studies at the Lutheran college in Prešov. After his father Stephen Thokoly was killed in the siege of Orava, Imre retreated to Transylvania where he joined an ongoing fight against Habsburg rule over Hungary. There he quickly gained favor among banished Hungarian nobles and Protestants. He was first proclaimed king of Upper Hungary in 1682 and later prince of Transylvania in 1690. By means of searching for an ally against the Habsburgs he soon drew close to the Ottomans. At some crucial clashes and standpoints in the great Turkish War, such as the battles of Senta and Slankamen, he led the Ottoman cavalry in combat. Imre Thokoly was expelled from the Treaty of Karlowitz in 1699 and therefore permanently retreated, with his spouse Illona Zrinyi, to Galata near Constantinopole.