Jerusalem was conquered by the Christian First Crusade in 1099, after it had been under the Muslim rule for 450 years. It became the capital of the Christian Kingdom of Jerusalem, until it was again conquered by the Ayyubids in 1187. For the next 2 months, a series of Christian campaigns (the Third, Fourth and Fifth Crusades) attempted in vain to retake the city, until Frederick II, Holy Roman Emperor leading the Sixth Crusade successfully negotiated its return in 1229. In 1244, the city was taken by the Khwarazmian dynasty and mostly destroyed. After 1250, it came under the rule of the Mamluk sultanate and was gradually rebuilt during the later 13th century.