In 1238 al-Kamil died and was succeeded by his son Al-Adil, as-Salih's brother; by 1240 as-Salih had overthrown him and taken control of Egypt. In 1244 the Khwarezmians 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 and the Khwarezmians defeated as-Salih's uncle 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. The next year the combined forces of the Ayyubids defeated the unruly Khwarezmians, who no longer recognized as-Salih as their lord.
In 1249 Louis IX of France invaded Egypt on the Seventh Crusade, and occupied Damietta. As-Salih was away fighting his uncle in Syria, but quickly returned and encamped at al-Mansourah, where he died after having his leg amputated in an attempt to save his life from a serious abscess affliction in November. As-Salih's heir, al-Muazzam Turanshah, was far away in Hasankeyf, and his widow, Shajar al-Durr, hid his death until Turanshah arrived. Nevertheless, the Mamluks, whom as-Salih had mostly recruited from the Kipchak Turks, gained power in Egypt, and were ultimately responsible for defeating the crusade. Their dynasty, the Bahri dynasty, were named after their barracks on an island in the Nile (Bahr al-Nil). The Bahriyya were also called Salihiyya, after as-Salih. The Mamluks did not control Syria, however, and as-Salih was the last Ayyubid to rule a united territory.
As-Salih had also purchased a slave who would later become Sultan. He purchased Qalawun al-Alfi for 1000 dinars. He was called al-Alfi ['the Thousand-man'] because he was bought for a thousand dinars of gold. Qalawun was an important Sultan in the Bahri dynasty of Mamlukes.