In 1075, it was finally lost to the Fatimids on its conquest by Tutush I, Seljuk emir of Damascus. It was briefly held by Muslim ibn Quraysh, emir of Aleppo, in 1083; after its recovery, it was ruled in the Seljuks' name by the eunuch Gümüshtegin until he was deposed for conspiring against the usurper Toghtekin in 1110. Toghtekin then gave the town to his son Buri. Upon Buri's succession to Damascus on his father's death in 1128, he granted the area to his son Muhammad. After Buri's murder, Muhammad successfully defended himself against the attacks of his brothers Ismaʿil and Mahmud and gave Baalbek to his vizier Unur. In July 1139, Zengi, atabeg of Aleppo and stepfather of Mahmud, besieged Baalbek with 14 catapults. The outer city held until October 10 and the citadel until the 21st, when Unur surrendered upon a promise of safe passage. In December, Zengi negotiated with Muhammad, offering to trade Baalbek or Homs for Damascus, but Unur convinced the atabeg to refuse. Zengi strengthened its fortifications and bestowed the territory on his lieutenant Ayyub, father of Saladin. Upon Zengi's assassination in 1146, Ayyub surrendered the territory to Unur, who was acting as regent for Muhammad's son Abaq. It was granted to the eunuch Ata al-Khadim, who also served as viceroy of Damascus.