hence As-Salih became the paramount ruler of the Ayyubid family. Rise of the Mamluks Once installed in Cairo, As-Salih was far from secure. The complex nature of the Ayyubid state meant that the ruling family itself, as well as associated Kurdish clans, had divided loyalties. Within Egypt, a powerful faction of Emirs, the Ashrafiyya, were conspiring to depose him and replace him with his uncle, as-Salih Ismail, who had regained control of Damascus after his departure. As-Salih shut himself in the Cairo citadel, and could no longer trust even the once-loyal Emirs who had brought him to power. The lack of loyal soldiers led him to begin buying large numbers of Kipchak slaves, who were available in unusually large numbers following the Mongol invasions in central Asia. They soon formed the core of his army, and were known as Mamluks. As-Salih was not the first Ayyubid ruler to make use of Mamluks, but he was the first to depend on them so heavily. Rather than just recruiting small numbers of Mamluks, As-Salih established two complete corps of them, numbering up to 1000 men. One unit was known as the 'River Corps' or Baḥrīyah or Bahriyya, because they were garrisoned at Rawḍah island in the River Nile. The second, smaller corps was the Jamdārīyah, which appears to have operated as a body guard for As-Salih. As the Mamluks would eventually overthrow the Ayyubid dynasty and take power on their own, their early rise to prominence under As-Salih Ayyub is of considerable historical importance. In English, references to the Bahriyya after As-Salih's death, when they became the dominant power in Egypt, usually describe them as the Bahri Mamluks. The members of the Bahriyya who were recruited by As-Salih himself are also sometimes referred to as the Salihiyya. During his lifetime these terms were synonymous. Wars with other Ayyubid realms and the Crusaders 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,