Ismail, with the support of the Ayyubids of Kerak, Hama and Homs, captured Damascus from Ayyub in September 1239. Ayyub was abandoned by his troops and taken captive by local Bedouin who transferred him to an-Nasir Dawud's control. This ushered in an era of future rivalry between Ismail and Ayyub. Ayyub eventually ascended to rule the Egypt-based sultanate with Dawud's help, but he soon quarreled with him. Dawud and Ismail had reconciled and decided to establish an alliance with the Crusaders to prevent Ayyub from conquering their territories. In July 1240 during the Barons' Crusade, an agreement was brokered via Theobald I of Navarre, with the Crusaders allying with Damascus against Egypt. The Crusaders would secure the southern border of Palestine from Ayyub, while Ismail was forced to effectively cede all of the land west of the Jordan River that Saladin had gained for the Ayyubids in 1187, including Jerusalem, Bethlehem, Gaza, and Nablus. Ismail also gave up his own fortresses in Hunin, Tiberias, Beaufort, and Safad. The terms of the treaty provoked outcries and consternation throughout the Arab world, and Muslim imams denounced Ismail because of the loss of Jerusalem.