Constantinople ended with Bayezid's defeat against the Timurids at the Battle of Ankara in 1402. In the aftermath of this battle, John VII negotiated a favourable treaty with one of Bayezid's sons, Süleyman Çelebi, which ensured that the important city of Thessalonica, lost to the Ottomans in 1387 due to the actions of Manuel, was returned to imperial control. Despite John VII's loyal service, Manuel sent him away in disgrace once he returned in 1403, and the two were once more enemies. This feud proved to be brief, as they were reconciled a few months later and a new agreement was made, in which John VII was allowed to take possession of Thessalonica and was acknowledged with the full imperial title. From 1403 until his death in 1408, John VII thus ruled in Thessalonica as "Emperor of All Thessaly", with his own separate imperial court. The Thessalonians considered him an able ruler, and his work with local church affairs and improving the city's defensive structures garnered him a positive remembrance. Biography Background and early life John VII Palaiologos was born in 1370 as the only son of Andronikos IV Palaiologos and Keratsa of Bulgaria, a daughter of Emperor Ivan Alexander of Bulgaria. Andronikos IV was the first-born son of Emperor John V Palaiologos () and thus the legitimate heir to the Byzantine throne. The Palaiologos dynasty, in power since 1259/1261, was often plagued by infighting, with the emperors and princes of the family often being unable to cooperate among themselves, to the detriment of the empire. The main enemy of the Byzantines at this time was the Ottoman Empire, which throughout the 14th century conquered vast swaths of former imperial territory. John V had even agreed to serve the Ottoman sultan Murad I () as a tributary vassal. At this time, despite geopolitical adversity, Byzantine and Ottoman aristocrats were in close contact with each other. While John was serving on an Ottoman campaign in Anatolia, as per his vassalage agreement with Murad I, Andronikos and one of Murad I's sons, Savcı Bey, co-ordinated simultaneous revolts against their fathers. The two princes were defeated, captured and imprisoned within a few months, as their fathers joined forces to put down the revolts. Andronikos and Savcı suffered harsh punishment. Savcı was blinded and beheaded by Murad I, and though the sultan ordered John V to blind his son as well, the Byzantine emperor