a contingent of troops to support the Mongol invasion of Syria, which the Mamluk sultan of Egypt Qalawun successfully prevented after defeating the coalition at Homs. To punish the Hospitallers, Qalawun clandestinely raised an army in Damascus and besieged Margat on 17 April 1285. After a 38-day siege during which sappers and miners managed to dig several tunnels underneath the fortress's walls, a mine destroyed a salient of the southernmost wall. The defenders panicked and on discovering the numerous tunnels around the fortress, surrendered to the Mamluk commander Fakhr al-Din Mukri on 23 May, with Qalwun entering Margat two days later. The siege was witnessed by eleven-year-old Abu'l Fida and his father, the Ayyubid governor of Hama. Qalawun allowed the Hospitallers to leave with everything they could carry. Rather than destroy Margat as he did with other fortresses, he repaired its defences and placed a strong garrison there due to its strategic value. Marqat, known as Marqab by the Muslims, became a district of the Mamluk province of Tripoli with maintenance of the area financed by the sultan. Intrepid traveller Ibn Battuta visited the fortress and noted that a suburb was built outside of it for foreigners, who were not allowed entry into the fortress. The district governor based at the Marqab fortress held the military rank of "Emir of 20 Mamluks." He was charged with defending the coast, particularly from threats from the island of Cyprus, and maintaining the guard towers and observation posts. During the Burji Mamluk period, Margat was well known in the region for containing an imperial prison with many high-profile inmates. The 15th-century Muslim historian Khalil al-Zahiri noted that Marqab fortress was among the most important sites of Tripoli province. Marqab was "clearly impregnable and controls a territory containing numerous villages." During the Ottoman era, Margat became the administrative center of a kaza ("district") of the same name, which contained three nahiyas ("subdistricts") — Margat, Qadmus and Khawabi. In the 1890s there was a total of 393 localities with a collective population of 39,671, of whom 21,121 were Alawites. The chief agricultural products were olives, onions, tobacco and silk, which were largely marketed to Beirut-based merchants. The fortress served as the residence of the kaymakam ("military governor") of the district until 1884 when the seat was transferred to Baniyas. The last known owner of the castle was Al-Markabi family (“Al-Marqabi”) where the name was based