The Ayyubids were still divided between Ayyub in Egypt, Isma'il in Damascus, and Dawud in Kerak. Isma'il, Dawud, and al-Mansur Ibrahim of Homs went to war with Ayyub, who hired the Khwarazmians to fight for him. The Khwarazmians were nomadic Turks from central Asia, who had recently been displaced by the Mongols further to the east and were now residing in Mesopotamia. With Ayyub's support they sacked Jerusalem in the summer of 1244, leaving it in ruins and useless to both Christians and Muslims. In October, the Khwarazmians, along with the Egyptian army under the command of Baibars, were met by the Frankish army, led by Philip of Montfort, Walter of Brienne, and the masters of the Templars, Hospitallers, and Teutonic Knights, along with al-Mansur and Dawud. On October 17 the Egyptian-Khwarazmian army destroyed the Frankish-Syrian coalition, and Walter of Brienne was taken captive and later executed. By 1247, Ayyub had reoccupied most of the territory that had been conceded in 1239, and had also gained control of Damascus.