The period 1240–1243 was largely occupied with complex military and diplomatic manoeuvres involving the Crusader states in Palestine and the European armies that arrived during the Barons' Crusade, other Ayyubid family rulers in Syria, and the Khwarezmians of Diyar Mudar who had previously been allied to as-Salih. Just as his Bahri Mamluks were important in enabling him to maintain order in Egypt, the Khwarezmians were useful in dominating the other Ayyubid rulers in neighbouring regions. In 1244, at As-Salih's invitation the Khwarezmians advanced through Syria and Palestine and sacked Jerusalem, which had been handed over to Frederick II, Holy Roman Emperor by al-Kamil during the Sixth Crusade. Later that year as-Salih, again allied to the Khwarezmians, defeated as-Salih Ismail in Syria, who had allied with the crusader Kingdom of Jerusalem, at the Battle of La Forbie. In 1245 as-Salih captured Damascus, and was awarded the title of sultan by the caliph al-Musta'sim in Baghdad. As-Salih was not however able to extend his rule far beyond Damascus, although he was able to retain the emirate of Baalbek under Saʿd al-Din al-Humaidi. In 1246 he decided that his Khwarezmian allies were dangerously uncontrollable, so he turned on them and defeated them near Homs, killing their leader and dispersing the remnants throughout Syria and Palestine. As-Salih's capture of Jerusalem after the Khwarezmian sacking led to the call for a new Crusade in Europe, and Louis IX of France took up the cross. The campaign took several years to organise, but in 1249 Louis invaded Egypt on the Seventh Crusade, and occupied Damietta.