Qadi al-Fadil

Muhyi al-Din (or Mujir al-Din) Abu Ali Abd al-Rahim ibn Ali ibn Muhammad ibn al-Hasan al-Lakhmi al-Baysani al-Asqalani, better known by the honorific name al-Qadi al-Fadil (; 3 April 1135 – 26 January 1200) was an official who served the last Fatimid caliphs, and became the secretary and chief counsellor of the first Ayyubid sultan, Saladin. 
Born in Ascalon to a qadi and financial official, Qadi al-Fadil went to study in Cairo, the Fatimid capital. He entered the Fatimid chancery, and quickly distinguished himself for the elegance of his prose style. In the early 1160s, he was patronized by the viziers Ruzzik ibn Tala'i and Shawar, rising to become head of the fiscal department supervising the army, and receiving the name by which he is known. Despite his prominent position in the Fatimid state, he quickly sided with the fellow Sunni Saladin during the latter's vizierate, and supported him in deposing the Fatimid dynasty, which was achieved in 1171.
In the new Ayyubid regime, he was an important figure, serving as Saladin's chief counsellor and was left in charge of the Egyptian administration during Saladin's wars in the Levant. As a result historians often attribute to him the title of vizier, which he never held. After Saladin's death in 1193, he served his son al-Afdal, ruler of Damascus, before switching his allegiance to al-Aziz, ruler of Egypt. He retired after 1195, and died in 1200. 
His reputation among contemporaries and later generations rests chiefly on his skill as an epistolary writer. His style was much admired and widely emulated by later generations. The corpus of his letters is also an important historical source for the period. In addition, he founded a madrasah in Cairo, and donated his large library to the institution.
Life.
Service under the Fatimids.
Qadi al-Fadil was born on 2 April 1135 at Ascalon. His father, known as al-Qadi al-Ashraf (d. 1149/50), was serving as judge () and financial comptroller () there. The exact significance of the epithet 'al-Baysani' is unclear: one version holds that the family hailed from Baysan, while another that it hailed from Ascalon, but that Qadi al-Ashraf had previously served as at Baysan. 
Qadi al-Fadil received his basic education at his home town, before moving to Cairo in , where, at the initiative of his father, he entered the chancery () of the Fatimid Caliphate as a trainee. The long-serving head of the chancery, Ibn Khallal, became his patron during his subsequent career. This training included administrative practice and especially the arts of epistolary and secretarial writing. Despite his own title of , however, it is unclear whether Qadi al-Fadil also received judicial education at any point. The title was common for officials in the Fatimid administration as a honorific, and under the Isma'ili Shi'a Fatimid regime, there were no Sunni schools in Cairo where he, as a Sunni, might have acquired the necessary training.
According to the 13th-century encyclopaedist Yaqut al-Hamawi, at this time Qadi al-Fadil's father fell into disgrace because he failed to inform Cairo of the release of an important hostage by the governor of Ascalon. His property was confiscated, and he died, destitute, soon after. According to this account, Qadi al-Fadil had to interrupt his apprenticeship and go on foot to Alexandria, where by 1153 he had become secretary to the of Alexandria, Ibn Hadid. His small salary of three gold dinars per month did not suffice to care for his mother, brother and sister back in Ascalon, but following the fall of Ascalon to the Crusaders in the same year, the rest of his family moved to Egypt. Alexandria was the seat of a Maliki law school, but it is again unknown if he attended it. The only available information comes from the later writer al-Mundhiri, who reports that during his stay in Alexandria, Qadi al-Fadil studied under the two eminent jurists Abu Tahir al-Silafi and Ibn Awf. In this post he distinguished himself due to the artful language of his dispatches, and was called to Cairo by the vizier Ruzzik ibn Tala'i (vizierate: 1161–1163) and appointed head of the army bureau ().
When Ruzzik was deposed by Shawar, Qadi al-Fadil became the secretary to Shawar's son, Kamil. During Shawar's conflicts with Dirgham, he sided with the former, and was even imprisoned for a time along with Kamil in August 1163, when Dirgham seized power. After the final victory of Shawar in May 1164, Qadi al-Fadil was released and given many honours, including the epithet of (), by which he is known.
Switch of allegiance and the fall of the Fatimid Caliphate.
As a partisan of Shawar, Qadi al-Fadil had originally opposed Shirkuh, the Kurdish general who had invaded Egypt on behalf of his Syrian master, Nur al-Din. Qadi al-Fadil's support extended to supporting Shawar's decision to turn to the Crusaders for aid against the Syrian troops. Nevertheless, within a short time, he managed to gain the friendship of Shirkuh and remained in service in the chancery under both him and his nephew and successor, Saladin. The sources give different accounts of the background of these events. Modern historians generally consider the truthfulness of these reports doubtful, as they are at pains to exculpate Qadi al-Fadil for his sudden change of allegiance from the Fatimids to the Ayyubids.
This change is not difficult to understand. Although a high official of the Fatimid state, Qadi al-Fadil was likely a devoted Sunni, as were most of the civilian bureaucracy at the time. His loyalty to the Fatimid dynasty and the Isma'ili sect was therefore dubious at best, and it was not difficult for him to transfer his allegiance to the Sunni Ayyubids. The Fatimid regime itself was already in decline, challenged by over-mighty viziers who had reduced the caliphs to puppets. The official sect of Isma'ilism had lost its appeal and was weakened by disputes and schisms, and the dynasty's legitimacy was increasingly challenged by a Sunni resurgence that was partly sponsored by the Fatimids' own viziers. 
In 1167/8, Qadi al-Fadil became the new head of the chancery, replacing his old patron Ibn Khallal. When the latter died on 4 March 1171, he became the secretary to Saladin. From 1170 on, Saladin gradually moved to dismantle the Fatimid regime and replace Isma'ilism with Sunni Islam. The 14th-century Egyptian historian al-Maqrizi ascribes to Saladin and Qadi al-Fadil jointly the common cause of deposing the Fatimid dynasty, and Saladin himself is said to have remarked "I took Egypt not by force of arms but by the pen of Qadi al-Fadil".
When Saladin deposed the Fatimid regime outright following the death of caliph al-Adid in September 1171, Qadi al-Fadil played a leading role in carrying out the subsequent changes in the military and fiscal administration of Egypt. Qadi al-Fadil's role in the suppression of a supposed pro-Fatimid conspiracy in April 1174 is unclear. The aftermath included the execution of a number of former Fatimid officials, most notably the poet Umara ibn Abi al-Hasan al-Yamani. Qadi al-Fadil's account of the extent of the conspiracy is at odds with the limited reprisals, and the affair was likely a settling of old rivalries within the former Fatimid administrative elites.
Service under Saladin.
Imad al-Din al-Isfahani, a friend and collaborator who entered Saladin's service through Qadi al-Din's intercession, writes of him that he was the "principal driving force behind the affairs of Saladin's regime", but his exact duties are unclear. Although often called Saladin's vizier, Qadi al-Fadil never held that title. He was nevertheless the closest counsellor and chief secretary of the Ayyubid ruler until Saladin's death. He accompanied Saladin in his campaigns in Syria, but in the sources, he is chiefly associated with Egypt, where most of his career took place. Thus in 1188/89 Saladin renewed Qadi al-Fadil's brief to supervise all affairs of Egypt, while in 1190/91 he was tasked with equipping a fleet to assist Saladin in his Siege of Acre. 
At the same time, during Saladin's absence in the wars against the Crusaders, the government of Egypt was formally left to other members of the Ayyubid clan. Qadi al-Fadil was critical of Saladin's brother, al-Adil. After he left Egypt, Qadi al-Fadil successfully lobbied for al-Adil's replacement by his friend, Saladin's nephew Taqi al-Din. For unknown reasons, Qadi al-Fadil was not present at Saladin's greatest victory at the Battle of Hattin (1187), nor in the subsequent recapture of Jerusalem.
In Christian sources, Qadi al-Fadil is blamed for the anti- purge of the early years of Saladin's rule, which saw Christians evicted and banned from holding posts in the public fiscal administration. At the same time, however, Qadi al-Fadl sponsored a number of Jewish physicians, among them the celebrated philosopher Maimonides, whom he defended from charges of apostasy, and who dedicated his book "On Poisons and Antidotes" to his patron.
From his prominent post, Qadi al-Fadil became a wealthy man: he reportedly received an annual salary of 50,000 gold dinars, and became a successful merchant, trading with India and North Africa. Outside the city walls of Cairo, a change of the course of the Nile had exposed large tracts of land that were exceedingly fertile. Qadi al-Fadil bought much of it, and converted these estates into an orchard that supplied the capital with fruit.
Final years and death.
After Saladin's death at Damascus in March 1193, Qadi al-Fadil initially served his oldest son al-Afdal, ruler of Damascus. Due to al-Afdal's erratic leadership, he quickly returned to Egypt, where he entered the service of al-Aziz, Saladin's second son, who had seized power there. When the two brothers came into conflict, Qadi al-Fadil managed to mediate a peace between them in 1195. After this he retired, and died on 26 January 1200. He was buried in the Qarafa cemetery in Cairo. A mausoleum was erected on top of his grave.
Qadi al-Fadil's surviving family is mostly obscure. From his many sons, only al-Qadi al-Ashraf Ahmad Abu'l-Abbas is notable, who served the Ayyubid rulers of Egypt until his death in 1245/46.
Writings and patronage of learning.
Already during his lifetime, Qadi al-Fadil was highly esteemed, chiefly due to the "exceptional quality of his private and official epistolary style", which was praised, held up as a model, and emulated by subsequent generations of writers. This style was similar to that of Imad al-Din al-Isfahani, and "combines richness (perhaps a little less prolix) and suppleness of form with a realistic treatment of the facts, a lesson too often forgotten by later writers, which makes his correspondence a valuable historical source". Al-Isfahani himself praises his contemporary as the "lord of word and pen", and writes that just as the Sharia invalidated all previous laws, so Qadi al-Fadil's style overrode all previous traditions in epistle literature (). As a result, many of his chancery epistles were included in the works of other authors, from chroniclers such as al-Isfahani and Abu Shama to compilers of literature, most notably al-Qalqashandi. Others survive as manuscripts to this day, and the work of editing and publishing them is still ongoing. However, they still represent only a part of the reportedly 100 volumes of official and private correspondence attributed to him.
As head of the chancery, Qadi al-Fadil also kept an official diary (known as or ). It has not survived, apart from several extracts from it that have been included in later histories, notably al-Maqrizi, and is an invaluable source on Saladin's rule in Egypt. According to the 13th-century historian Ibn al-Adim, however, this diary was actually kept by a different historian, Abu Ghalib al-Shaybani.
Qadi al-Fadil was also active as a poet. Many of his works are included in his epistles. His were published in two volumes in Cairo in 1961 and 1969, edited by Ahmad A. Badawi and Ibrahim al-Ibyari. 
A famous bibliophile, Qadi al-Fadil amassed a large library, much of which he donated to a madrasah for Maliki and Shafi'i jurisprudence that he founded in 1184/85 at Cairo, the Fadiliyya. It included a hall for studying the recitation of the Quran, an orphanage, and Qadi al-Fadil's private residence. His son Ahmad served there as a teacher, and a grandson worked there as librarian.