Al-Kamil

Al-Kamil () (full name: al-Malik al-Kamil Naser ad-Din Abu al-Ma'ali Muhammad) (c. 1177 – 6 March 1238) was a Muslim ruler and the fourth Ayyubid sultan of Egypt. During his tenure as sultan, the Ayyubids defeated the Fifth Crusade. He was known to the Frankish crusaders as Meledin, a name by which he is still referred to in some older western sources. As a result of the Sixth Crusade, he ceded Jerusalem to the Christians and is known to have met with Saint Francis.
Biography.
Jazira campaign.
Al-Kamil was the son of sultan al-Adil ("Saphadin"), a brother of Saladin. Al-Kamil's father was laying siege to the city of Mardin (in modern-day Turkey) in 1199 when he was called away urgently to deal with a security threat in Damascus. Al-Adil left al-Kamil to command the forces around Mardin continuing the siege. Taking advantage of the Sultan's absence, the combined forces of Mosul, Sinjar and Jazirat ibn Umar appeared at Mardin when it was on the point of surrender, and drew Al-Kamil into battle. He was badly defeated and retreated to Mayyafariqin. However dissent and weakness among his opponents meant that Al-Kamil was able to secure Ayyubid rule in the Jazira Region by taking Harran (in modern-day Turkey).
Viceroy of Egypt.
In 1200, after proclaiming himself Sultan, Al-Adil invited Al-Kamil to come from the Eastern Territories to join him in Egypt as his viceroy (na'ib) in that country. Al-Adil's second son, Al-Mu'azzam Isa, had already been made prince of Damascus in 1198. It appears that Al-Adil allowed Al-Kamil a fairly high degree of authority, since he oversaw much of the work on the Cairo Citadel, issued decrees in his own name, and even managed to persuade his father to dismiss the powerful minister Ibn Shukr. Al-Kamil remained viceroy until his father's death in 1218 when he became Sultan himself.
The Fifth Crusade.
In 1218 when Al-Adil died, the Ayyubid domains were divided into three parts, with Al-Kamil ruling Egypt, his brother Al-Muazzam Isa ruling in Palestine and Transjordan, and a third brother, 
Al-Ashraf Musa in Syria and the Jazira. Nominally the other two recognised Al-Kamil's supremacy as Sultan. Unusually for an Ayyubid succession, there was no obvious dissent or rivalry between the brothers at this point, partly because just before Al-Adil's death, Egypt had been attacked by the forces of the Fifth Crusade.
Al-Kamil took command of the forces which defended Damietta against the Crusaders. In 1219 he was almost overthrown by a conspiracy led by the amir Imad ad-Din ibn al-Mashtub, commander of the Hakkari Kurdish regiment, to replace him with his younger and more pliant brother al-Faiz Ibrahim. Alerted to the conspiracy, Al-Kamil had to flee the camp to safety and in the ensuing confusion the Crusaders were able to tighten their grip on Damietta. Al-Kamil considered fleeing to Yemen, which was ruled by his son Al-Mas'ud, but the timely arrival of his brother Al-Muazzam from Syria with reinforcements brought the conspiracy to a swift end.
Al-Kamil made many offers of peace to the Crusaders, all of which were rejected, due to the influence of the papal legate Pelagius. He offered to return Jerusalem and rebuild its walls (which his brother had torn down earlier in the year), and to return the True Cross (which he probably did not have). At one point he even negotiated with Francis of Assisi, who had accompanied the crusade, and who apparently tried to convert the sultan.
Due to famine and disease after the Nile failed to flood, al-Kamil could not defend Damietta and it was captured in November 1219. The sultan withdrew to al-Mansourah, a fortress further up the Nile. After this there was little action until 1221, when al-Kamil offered peace again, proposing to surrender the entire territory of the Kingdom of Jerusalem, except Transjordan, in return for the Crusaders evacuating Egypt but was again refused. The Crusaders marched out towards Cairo, but al-Kamil simply opened the dams and allowed the Nile to flood, and finally the Crusaders accepted an eight-year peace. He retook Damietta in September.
Power struggle and the treaty of 1229.
In the following years there was a power struggle with his brother al-Mu'azzam, and al-Kamil was willing to accept a peace with emperor and King of Sicily Frederick II, who was planning the Sixth Crusade. Al-Mu'azzam died in 1227, eliminating the need for a peace, but Frederick had already arrived in Palestine. After al-Mu'azzam's death, al-Kamil and his other brother al-Ashraf negotiated a treaty, giving all of Palestine (including Transjordan) to al-Kamil and Syria to al-Ashraf. In February 1229 al-Kamil negotiated a ten-year peace with Frederick II and returned Jerusalem and other holy sites to the Crusader kingdom. The treaty of 1229 is unique in the history of the Crusades. By diplomacy alone and without major military confrontation, Jerusalem, Bethlehem, and a corridor running to the sea were ceded to the kingdom of Jerusalem. Exception was made for the Temple area, the Dome of the Rock, and the Aqsa Mosque, which the Muslims retained. Moreover, all current Muslim residents of the city would retain their homes and property. They would also have their own city officials to administer a separate justice system and safeguard their religious interests. The walls of Jerusalem, which had been destroyed, were rebuilt, and the peace was to last for 10 years. However although there was peace with the Crusaders, al-Kamil had to contend with the Seljuks and the Khwarezmians before he died in 1238.
Successors.
His sons as-Salih Ayyub and al-Adil II succeeded him in Syria and Egypt respectively, but the Ayyubid empire soon descended into civil war. In 1239 the treaty with Frederick expired, and Jerusalem came under Ayyubid control.
Personality.
Al-Kamil exemplified the Islamic laws of war. For example, after al-Kamil defeated the Franks during the Crusades, Oliverus Scholasticus praised and commented on how al-Kamil supplied the defeated Frankish army with food: