Imam Ali (A.S) is Holy Prophet’s Heir
Sayyid 'Abd al-Hussein Sharaf al-Din al-Musawi al-
There is no doubt that the Messenger of Allah, peace be upon him and his progeny, has left `Ali with a legacy of knowledge and wisdom as much as the Almighty permitted His prophets and wasis to inherit, so much so that the Messenger of Allah (PBUH) has said: "I am the city of knowledge and Ali is its gate; therefore, whoever wishes to attain knowledge, let him approach through the gate."
He, peace be upon him and his progeny, has said: "I am the storehouse of wisdom, and `Ali is its door... `Ali is the gateway of my knowledge, the one who explains after me the Message with which I have been sent; loving him is indicative of genuine faith, and hating him is hypocrisy." According to Zayd ibn Abu `Awfah, he, peace be upon him and his progeny, has addressed `Ali thus: "You are my brother and heir;" whereupon `Ali inquired: "And what will you bequeath unto me?" He, peace be upon him and his progeny, answered: "Whatever Prophets before me used to bequeath." In another hadith, he, peace be upon him and his progeny, according to Buraydah, has said: "The heir of my knowledge is `Ali." Refer also to the hadith on the day of warning. During the lifetime of the Messenger of Allah, peace be upon him and his progeny, `Ali (A.S) used to say: "By Allah, I am his brother, successor and cousin, and the heir of his knowledge; so, who is more worthy of all this other than myself?"
Once `Ali was asked: "How did you come to inherit your cousin rather than your uncle?" He answered: "The Messenger of Allah, peace be upon him and his progeny, gathered the descendants of `Abdul Muttalib, who were quite a few, and each one of them had such an appetite that would consider tree trunks edible and would drink water though not potable, and he prepared for them a mudd of food (a dry measure approximately Tangier 46.61, about one and three-quarter of a pound); yet they all ate till they were satisfied, while the food looked as if it was not touched. Then he, peace be upon him and his progeny, said: `O descendants of `Abdul Muttalib! I have been sent to you in particular, and to all people in general; so, who among you pledges to be my brother, friend and heir?' Nobody stood; so, I stood, though the youngest among the attendants, but he (PBUH) told me to sit. He repeated his statement twice, and each time, I was the only one who stood up, and every time he would tell me to sit. On the third time, he shook hands with me; thus did I come to inherit my cousin instead of my uncle.'"
According to al- Hakim's Al-Mustadrak,  and to al-Thahbi's Talkhis, who both testify to its authenticity, Qatham ibn al-`Abbas was asked once: "How did `Ali come to inherit the Messenger of Allah (PBUH) rather than your own selves?" He answered: "It is so due to his being the foremost among us in following him, and in keeping company with him more than anyone of us."
It was well known that `Ali, rather than his uncle al-`Abbas or any descendant of Hashim, was the heir of the Messenger of Allah, peace be upon him and his progeny. They accepted that as a fact, though they were informed of the reason why such inheritance was confined to `Ali alone, who was the Prophet's cousin, rather than to al `Abbas, his uncle, or to any other uncle or relative of the Prophet, peace be upon him and his progeny. For this reason, they used to ask `Ali (A.S) once and once Qatham, and the latter used to answer them as stated above in a way that is satisfactory to the understanding of those inquirers.
Otherwise, the answer would be that Allah, the Exalted and omni Scient, looked upon the people of the earth and choose from among them Muhammad (PBUH) and elevated him to be the Prophet, then He cast another look and selected `Ali and inspired to His Messenger, peace be upon him and his progeny, to take him as his heir and successor.
On page 125, Vol. 3, of Al-Mustadrak, al Hakim, having quoted Qatham stating the above, says: "The judge of judges [supreme judge, or grand mufti], Abul-Hassan Muhammad ibn Salih al Hashimi, has told me that he once heard Abu `Umer the judge saying: `I heard Isma`il ibn Ishaq the judge, having been informed of what Qatham had said, saying that a man inherits another through either a blood relationship or sincere loyalty, and men of knowledge do not dispute the fact that [under normal circumstances] a cousin does not become the heir while the uncle [his father] is still alive.' According to such consensus, `Ali inherited the Prophet's knowledge rather than them." As a matter of fact, chroniclers are sequential in narrating such a fact, especially through the sources of the purified progeny, and suffices us for proof is the Will and its clear texts, Wassalam.
 This statement verbatim is confirmed as being `Ali's. It is quoted by al-Hakim on page 126, Vol. 3, of his Al-Mustadrak through a narration endorsed by al-Bukhari and Muslim. Al-Thahbi, in his Talkhis al-Mustadrak, has admitted the same.
 This hadith stands on firm grounds, and it is a lengthy one. It has been quoted by al-Diya' al-Maqdisi in his Al-Mukhtara, and by Ibn Jarir in his Tahthib al-Athar. It is hadith number 6155 on page 408, Vol. 6, of Kanz al-`Ummal. It is also quoted by al-Nisa'i on page 18 of his Al-Khasa'is al-`Alawiyya, and it is transmitted by Ibn Abul-Hadid from al-Tabari's Tarikh near the end of the commentary on the "qasi`a" sermon, page 255, Vol. 3, of Sharh Nahjul Balaghah. Refer also to page 159, Vol. 1, of Imam Ahmed ibn Hanbal's Musnad where you will find the same hadith conveying this meaning.
 It occurs on page 125 of its third volume. It is also quoted by Ibn Abu Shaybah, and it is hadith number 6084 on page 400, Vol. 6, of Kanz al-`Ummal.