The following is excerpted from Ibn Khaldun’s Muqaddimah, the introduction to his universal history (which can be found here: http://www.muslimphilosophy.com/ik/Muqaddimah/). Ibn Khaldun, unlike many of his contemporaries or predecessors in the Muslim world, was convinced of the authenticity of Fatimid claims to Alid descent. As one of the foremost philosophers and historians of the medieval period, Ibn Khaldun’s defense of Fatimid lineage (even as he condemns the dynasty for belonging to a “heretical sect”) deserves to be considered.
“[Another example of] ludicrous information which is accepted by many historians concerns the ‘Ubaydid (-Fatimids), the Shi’a caliphs in Qayrawan and Cairo. (These historians) deny their Alid origin and attack (the genuineness of) their descent from the Imam Ismail, the son of Ja’far al-Sadiq. They base themselves in this respect on stories that were made up in favor of the weak Abbasid caliphs by people who wanted to ingratiate themselves with them through accusations against their active opponents and who (therefore) liked to say all kinds of bad things about their enemies. We shall mention some such stories in our treatment of the history of (the Fatimids). (These historians) do not care to consider the factual proofs and circumstantial evidence that require (us to recognize) that the contrary is true and that their claim is a lie and must be rejected.
They all tell the same story about the–beginning of the Shi’a dynasty. Abu ‘Abdallah went among the Kutama Berbers urging acceptance of the family of Muhammad (the Alids). His activity became known. It was learned how much he cared for ‘Ubaydallah al-Mahdi and his son, Abu1-Qasim. Therefore, these two feared for their lives and fled the East, the seat of the caliphate. They passed through Egypt and left Alexandria disguised as merchants. Isa anNawshari, the governor of Egypt and Alexandria, was informed of them. He sent cavalry troops in pursuit of them, but when their pursuers reached them, they did not recognize them because of their attire and disguise. They escaped into the Maghrib. Al-Mu’tadid ordered the Aghlabid rulers of Ifriqiyah in Qayrawan as well as the Midrarid rulers of Sijilmasah to search everywhere for them and to keep a sharp lookout for them. Ilyasa, the Midrarid lord of Sijilmasah, learned about their hiding place in his country and detained them, in order to please the caliph. This was before the Shi’a victory over the Aghlabids in Qayrawan.
Thereafter, as is well known, the (Fatimid) propaganda spread successfully throughout Ifriqiyah and the Maghrib, and then, in turn, reached the Yemen, Alexandria and (the rest of) Egypt, Syria and the Hijaz. The (Fatimids) shared the realm of Islam equally with the Abbasids. They almost succeeded in penetrating the home country of the Abbasids and in taking their place as rulers. Their propaganda in Baghdad and Iraq met with success through the emir al-Basasiri, one of the Daylam clients who had gained control of the Abbasid caliphs. This happened as the result of a quarrel between al-Basasiri and the non-Arab emirs. For a whole year, the (Fatimids) were mentioned in the Friday prayer from the pulpits of Baghdad. The Abbasids were continually bothered by Fatimid power and preponderance, and the Umayyad rulers beyond the sea (in Spain) expressed their annoyance with them and threatened war against them. How could all this have befallen a fraudulent claimant to the caliphate? One should compare (this account with) the history of the Qarmatian. His genealogy was, in fact, fraudulent. How completely did his propaganda disintegrate and his followers disperse! Their viciousness and guile soon became apparent. They came to an evil end and tasted a bitter fate. If the Fatimids had been in the same situation, it would have become known, even had it taken some time.
The Fatimid dynasty lasted uninterruptedly for about two hundred and seventy years. They held possession of the place where Abraham had stood and where he had prayed, the home of the Prophet and the place where he was buried, the place where the pilgrims stand and where the angels descended (to bring the revelation to Muhammad). Then, their rule came to an end. During all that time, their partisans showed them the greatest devotion and love and firmly believed in their descent from the imam Ismail, the son of Ja’far as-Sadiq. Even after the dynasty had gone and its influence had disappeared, people still came forward to press the claims of the sect. They proclaimed the names of young children, descendants of Fatimids, whom they believed entitled to the caliphate. They went so far as to consider them as having actually been appointed to the succession by preceding Imams. Had there been doubts about their pedigree, their followers would not have undergone the dangers involved in supporting them. A sectarian does not manipulate his own affairs, nor sow confusion within his own sect, nor act as a liar where his own beliefs are concerned.
It is strange that Abu Bakr al-Baqillani‘the great speculative theologian, was inclined to credit this unacceptable view (as to the spuriousness of Fatimid genealogy), and upheld this weak opinion. If the reason for his attitude was the heretical and extremist Shi’ism of the Fatimids, it would not be valid, for his denial of their Alid descent does not invalidate the objectionable character of their sectarian beliefs, nor would establishment of their Alid descent be of any help to them before God in the question of their unbelief. God said to Noah concerning his sons: “He does not belong to your family. It is an improper action. So do not ask me regarding that of which you have no knowledge.” Muhammad even exhorted Fatimah in these words: “O Fatimah, act (as you wish). I shall be of no help to you before God.”
When a man comes to know a problem or to be certain about a matter, he must openly state his knowledge or his certainty. “God speaks the truth. He leads (men into) the right way.” Those people (the Fatimids) were constantly on the move because of the suspicions various governments had concerning them. They were kept under observation by the tyrants, because their partisans were numerous and their propaganda had spread far and wide. Time after time they had to leave the places where they had settled. Their men, therefore, took refuge in hiding, and their (identity) was hardly known, as (the poet) says:
If you would ask the days what my name is, they would not know,
And where I am, they would not know where I am.
This went so far that Muhammad, the son of the Imam Isma’il, the ancestor of Ubaydallah al-Mahdi, was called “the Concealed (Imam).” His partisans called him by that name because they were agreed on the fact he was hiding out of fear of those who had them in their power. The partisans of the Abbasids made much use of this fact when they came out with their attack against the pedigree of the Fatimids. They tried to ingratiate themselves with the weak Abbasid caliphs by professing the erroneous opinion that the Alid descent of the Fatimids was spurious. It pleased the Abbasid clients and the emirs who were in charge of military operations against the enemies of the Abbasids. It helped them and the government to make up for their inability to resist and repel the Kutama Berbers, the partisans and propagandists of the Fatimids, who had taken Syria, Egypt, and the Hijaz away from the Abbasids.
The judges in Baghdad eventually prepared an official statement denying the Alid origin of the Fatimids. The statement was witnessed by a number of prominent men, among them the Sharif ar-Radi and his brother al-Murtada, and Ibn al-Bathawi. Among the religious scholars (who also witnessed the document) were Abu Hamid al-Isfarayini, al-Quduri, as-Saymari, Ibn al-Akfani, al-Abiwardi, the Shi’a jurist Abu ‘Abdallah b. an-Nu’man, and other prominent Muslims in Baghdad. The event took place one memorable day in the year 402  in the time of al-Qadir. The testimony (of these witnesses) was based upon hearsay, on what people in Baghdad generally believed. Most of them were partisans of the ‘Abbasids who attacked the Alid origin of the Fatimids. The historians reported the information as they had heard it. They handed it down to us just as they remembered it. However, the truth lies behind it. Al-Mu’tadid’s letter concerning Ubaydallah (addressed) to the Aghlabid in Qayrawan and the Midrarid in Sijilmasah, testifies most truthfully to the correctness of the Alid origin of the Fatimids, and proves it most clearly. Al-Mu’tadid (as a very close relative) was better qualified than anyone else to speak about the genealogy of the Prophet’s house.”
(trans. Franz Rosenthal)