Hisn Kayfa to obtain its surrender. Even though, the Ayyubid force had brought with them al-Masʿud as a captive, the garrison at Hisn Kayfa resisted for some time, and the city was captured only in Safar 630/November 1232. Ayyubids and Mongols (1232–1462) Once the citadel fell to the Ayyubid forces, al-Kamil immediately installed his 27-year-old son, as-Salih Ayyub, as governor of both Amida and Hisn Kayfa, beginning the period of Ayyubid rule over the Diyar Bakr. Ayyubid rule of Hisn Kayfa was insecure almost from the start. During 1235, the Rum Seljuk forces of 'Alā ad-Dīn Kayqubād had advanced into Southeast Anatolia, capturing Harput, Urfa and Harran. In Dhu-l-Hijja 632/August 1235, they laid siege to Amida, but were unsuccessful in capturing the city and consequently did not advance as far as Hisn Kayfa. Only five years after Hisn Kayfa was captured by the Ayyubids, it had already become a pawn in the dynasty's power struggles. By al-Ashraf had become resentful of his brother al-Kamil's ill-concealed ambition. al-Ashraf recruited the rulers of Aleppo and Homs to his faction and sent ambassadors to the court of Rum Seljuk sultan 'Alā ad-Dīn Kayqubād to propose an alliance. When they arrived at the Seljuk court they discovered that Kayqubād had died on 4 Shawwal 634/31 May 1237, and they now had to deal with his son, Ghiyath ad-Din Kaykhusrau II. The Middle East historian R. Stephen Humphreys speculates that Kaykhusrau was offered control of Amida and Hisn Kayfa in return for joining the alliance. Although al-Ashraf had assembled a formidable alliance against his brother, he was unable to use this to engage al-Kamil's forces as he was already ill by the time of the negotiations with the Seljuks, and he died on 4 Muharram 635/28 August 1237. His rival, al-Kamil, died on 6 March 1238, and the Ayyubid domain was thrown into fresh turmoil. Al-Kamil had bequeathed control of the Jazira to as-Salih Ayyub, who had been emir of Hisn Kayfa, and named his younger brother al-Adil as his heir in Egypt. In his new role as sultan, as-Salih Ayyub installed his own young son, al-Muazzam Turanshah as prince of Hisn Kayfa in , with one of his closest advisers, Husam al-Din, as Turanshah's atabeg. As-Salih Ayyub, meanwhile, gathered an army to take Damascus and challenge al-Adil's rule over Egypt. By June 1240 as-Salih Ayyub's soldiers had captured al-Adil and as-Salih became paramount ruler