 Mamluks had formed a part of the state or military apparatus in Syria and Egypt since at least the 9th century, rising to become governing dynasties of Egypt and the Levant during the Tulunid and Ikhshidid periods.Mamluk regiments constituted the backbone of Egypt's military under Ayyubid rule in the late 12th and early 13th centuries, beginning with Sultan Saladin () who replaced the Fatimids' black African infantry with mamluks.Each Ayyubid sultan and high-ranking emir had a private mamluk corps.