Generally considered the greatest Arab historian and the father of Sociology and the sciences of History, Ibn Khaldun (in full Abu Zayd 'Abd al-Rahman ibn Khaldun) developed one of the earliest nonreligious philosophies of history in his masterwork, the Muqaddimah.
Khaldun's extraordinarily eventful life is chronicled in his autobiography, Al-ta'rif bi Ibn Khaldun. He came from an illustrious family and enjoyed an excellent education in his youth. Both his parents died when the Black Death struck Tunis in 1349.
At the age of 20 he was given a post at the court of Tunis, and later became secretary to the sultan of Morocco in Fez. In the late 1350s he was imprisoned for two years for suspicion of participating in a rebellion. After being released and promoted by a new ruler, he again fell out of favor, and he decided to go to Granada. Ibn Khaldun had served the Muslim ruler of Granada in Fez, and Granada's prime minister, Ibn al-Khatib, was a renowned writer and a good friend to Ibn Khaldun.
A year later he was sent to Seville to conclude a peace treaty with King Pedro I of Castile, who treated him with great generosity. However, intrigue raised its ugly head and rumors were spread of his disloyalty, adversely affecting his friendship with Ibn al-Khatib. He returned to Africa, where he changed employers with unfortunate frequency and served in a variety of administrative posts.
In 1375, Ibn Khaldun sought refuge from the tumultous political sphere with the tribe of Awlad 'Arif. They lodged him and his family in a castle in Algeria, where he spent four years writing the Muqaddimah. This superior work is not merely a history of the Arabs and Berbers, it is also a discussion of historical method and the development of a philosophy of history.
Illness drew him back to Tunis, where he continued his writing until difficulties with the current ruler prompted him to leave once more. He moved to Egypt and eventually took a teaching post at the Quamhiyyah college in Cairo, where he later became chief judge of the Maliki rite, one of the four recognized rites of Sunnite Islam. He took his duties as judge very seriously -- perhaps too seriously for most of the tolerant Egyptians, and his term did not last long.
During his time in Egypt, Ibn Khaldun was able to make a pilgrimage to Mecca and visit Damascus and Palestine. Except for one incident in which he was forced to participate in a palace revolt, his life there was relatively peaceful -- until Timur invaded Syria.
The new sultan of Egypt, Faraj, went out to meet Timur and his victorious forces, and Ibn Khaldun was among the notables he took with him. When the Mamluk army returned to Egypt, they left Ibn Khaldun in besieged Damascus. The city fell into great peril, and the city leaders began negotiations with Timur, who asked to meet Ibn Khaldun. The illustrious scholar was lowered over the city wall by ropes in order to join the conqueror.
Ibn Khaldun spent nearly two months in the company of Timur, who treated him with respect. The scholar used his years of accumulated knowledge and wisdom to charm the ferocious conqueror, and when Timur asked for a description of North Africa, Ibn Khaldun gave him a complete written report. He witnessed the sack of Damascus and the burning of the great mosque, but he was able to secure safe passage from the decimated city for himself and other Egyptian civilians.
On his way home from Damascus, laden with gifts from Timur, Ibn Khaldun was robbed and stripped by a band of Bedouin. With the greatest of difficulty he made his way to the coast, where a ship belonging to the Sultan of Rum, carrying an ambassador to the sultan of Egypt, took him to Gaza. Thus he estabished contact with the rising Ottoman Empire.
The rest of Ibn Khaldun's journey and, indeed, the rest of his life were relatively uneventful. He died in 1406 and was buried in the cemetery outside one of Cairo's main gates.