In 1250 the Ayyubid dynasty faltered and power transitioned to a regime controlled by the Mamluks. The mamluks were soldiers who were purchased as young slaves (often from various regions of Central Eurasia) and raised to serve in the army of the sultan. They became a mainstay of the Ayyubid military under Sultan al-Salih and eventually became powerful enough to assume control of the state for themselves in a political crisis during the Seventh Crusade. Between 1250 and 1517, the throne passed from one mamluk to another in a system of succession that was generally non-hereditary, but also frequently violent and chaotic. Nonetheless, the Mamluk Empire continued many aspects of the Ayyubid Empire before it, and was responsible for repelling the advance of the Mongols in 1260 (most famously at the Battle of Ain Jalut) and for putting a final end to the Crusader states in the Levant.