The Sources of the Imam's Knowledge
The exceedingly precise and profound knowledge possessed by the Imams is derived from their communication with the world of the unseen and from inspiration (ilham).
The Noble Qur'an was also a rich source on which the Immaculate Imams drew for their knowledge. Given the breadth of their religious vision and perception, they were able to derive various ordinances from revelation and to extract all manner of truths from its innermost layers of meaning.
The third source on which they drew consisted of the books and pages which they inherited from the Most Noble Messenger, peace and blessings be upon him and his family, these permitted them to advance still further their level of knowledge and to broaden its scope.
There are numerous traditions relating to these three sources, some of which we will now cite.
Imam Ja'far al-Sadiq, peace be upon him, said:
"The Prophet Dawud inherited the knowledge of the preceding prophets, and he then bequeathed it to Sulayman. From Sulayman it was transmitted to the Prophet Muhammad, peace and blessings be upon him and his family, and we in turn have inherited it from him."
Abu Basir who was present then saw fit to remark: "There are all kinds of knowledge!" The Imam responded! "The knowledge you have in mind is not particularly valuable. The knowledge of which I speak is truly precious; it is inspired in us night and day, from one hour to the next." 
Imam Ali b. Musa al-Rida, peace be upon him, said:
"When someone is chosen by God to administer the affairs of men, God expands his breast for him, places the well springs of wisdom in his heart, and inspires him with knowledge, so that he will be able to solve any problem that arises. He with know well the straight path of the truth. Such a one is none other than the Inerrant Imam, who enjoys the aid and support of his Lord and who lies beyond the reach of all error and sin." 
Hasan b. Abbas once asked Imam al-Rida, peace be upon him, in a letter. "What is the difference between a messenger, a prophet, and an Imam?" The Imam answered as follows:
"The messenger (rasul) is a person to whom Jibril descends and who both sees him and hears the words that he speaks. He is thus in communication with divine revelation (wahy), which he sometimes receives in the form of a dream, as was the case with Ibrahim, peace be upon him. The prophet (nabiyy) sometimes hears the words spoken by Jibril and at other times sees him without hearing anything from him. The Imam hears the words that Jibril utters without seeing him."
The seventh Imam, Musa b. Ja'far, peace be upon him, said:
"Our knowledge is of three kinds: relating to the past; relating to the future; and relating to newly emergent situations. Knowledge relating to the past is interpreted for us;
knowledge relating to the future is written down for us; and knowledge relating to newly emergent situations is infused in our hearts and our ears. This last category is the most noble part of our knowledge. However, no prophet will come after the Most Noble Messenger, peace and blessings be upon him and his family "
God's effusions of grace thus continue throughout time by means of the Inerrant Imam, in such a way that the link between man and the Creator is not severed with the passing of the Prophet.
As for the inexhaustible source that the Qur'an represented for the Immaculate Imams, let us hear what they themselves have to say on the subject:
Imam al-Baqir, peace be upon him, says:
"One of the forms of knowledge we possess pertains to the interpretation of the Qur'an and its ordinances, while another form relates to the developments and occurrences that take place in time. Whenever God desires a certain group of men to attain virtue and purity, He bestows on them the capacity to hear. However, one whose ear is incapable of hearing will encounter God's word in a way that suggests he has no awareness of it."
He then fell silent for a moment before continuing: "If we were to find anyone with the requisite spiritual capacity, we would transmit our knowledge to him. God is our protector and refuge." 
Imam Ja'far al-Sadiq, peace be upon him, says:
"The Noble Qur'an contains knowledge of the past and the future, as well as the precepts for judging; we have all of that knowledge." 
The Commander of the Faithful, Ali, peace be upon him, says:
"Try to make the Qur'an speak; it will not speak to you. I declare to you that the Qur'an contains knowledge of the past and the future, as well as all the ordinances of which you stand in need and the interpretation of matters concerning which you disagree among yourselves. If you but ask me, I will instruct you in all of this.'" 
One of the companions of Imam Musa b. Ja'far, peace be upon him, asked him:
"Is all that you say to be found in the Qur'an and the Sunnah of the Prophet, or do you also speak on your own authority?"
He replied: "It is impossible that we should say anything on our authority. Whatever we say is to be found in the Qur'an and the Sunnah of the Prophet." 
The interpretation of the inner meaning of the Qur'an is a science that derives from the world of the unseen; in other words, it is not a science that can be acquired by conventional means. Such interpretation, which is the uncovering of the true nature of things, words, and needs, can be attained only through bestowal by God.
The Qur'an says: "He it is who brought the Book down to you. Part of it consists of verses firm and categorical in meaning, these being the foundation of the Book, and part of others allegorical in meaning. Those in whose hearts is perversion and deviance follow only the metaphorical verses in order to create confusion and disorder while claiming to be interpreting those verses. Their interpretation is known, however, only to God and those firmly rooted in knowledge." (3:7)
"Those firmly rooted in knowledge" (al-rasikhuna fi 'l-'ilm) are then those who like God know the interpretation of the metaphorical verses, and there are numerous traditions testifying to the Imams' command of Qur'anic interpretation.
One of the companions of Imam al-Baqir, peace be upon him, asked him to explain the tradition that, "There is no part of the Qur'an that does not have an outer and an inner aspect, and there is no letter contained in it that does not have a defining limit, and that limit is knowable."
He replied: "The outer aspect of the Qur'an is the totality of that which has been revealed. Its inner aspect is the interpretation thereof. Part of this has already been accomplished, and part remains to be accomplished in the future. For the interpretation of the Qur'an traverses its course, like the sun and the moon, and whenever the time is apposite, a further portion of it is accomplished. God said: 'Its interpretation is known only to God and those firmly routed in knowledge.' We it is who are throughly acquainted with the interpretation of the Qur'an." 
Imam al-Sadiq, peace be upon him, is reported to have said: "The most exalted of those firmly rooted in knowledge was the Messenger of God. Whatever God Almighty Sent to him, He taught him also its interpretation. Indeed God has revealed nothing in the interpretation of which He has not instructed the Prophet and his successors, When one of those who has no share in the science of interpretation expresses an opinion on the subject, God responds to him, All they can say is, "We believe it all to be from God."' The Qur'an contains verses that are specific in their application and others that are general; verses that are categorical and others that are metaphorical; and verses that are abrogating and others that are abrogated. It is those firmly rooted in knowledge who have the knowledge of all this." 
Another source on which the Imams, the successors to the Prophet, drew, consists of the books and scrolls that they inherited from him.
Imam al-Sadiq, peace be upon him, said:
"We have at our disposal a book which frees us of the need to rely on anyone else; it is, on the contrary, others that need us. This book was dictated by the Prophet to Ali and it deals with everything relating to the forbidden and the permitted. Whenever you ask us concerning a given course of action, we know what consequences will result if you follow it, and what will happen if you do not," 
One of the close companions of Imam Ja'far al-Sadiq, peace be upon him, says:
"I asked the Imam whether the legacy of knowledge he had at his disposal related simply to the general principles of knowledge or contained detailed instructions on matters such as divorce and bequests."
"Ali, peace be upon him, wrote down all of the sciences of judgeship and bequests. Were our cause to triumph, no problem would arise that we could not solve by means of the knowledge we have." 
The Commander of the Faithful, Ali, peace be upon him, relates: "The Most Noble Messenger, peace and blessings be upon him and his family, told me to write down and record what he was about to tell me. I replied that I was afraid of forgetting it. He then told me: 'This will not happen, for I have beseeched God to make you a memorizer of the Qur'an. However, you should record what I am about to tell you for the sake of your partners, that is the Imams from your progeny. It is because of those blessed beings that the rain falls on my ummah, that their prayers are answered, that divine punishment is withheld, and God's mercy descends.' Then he pointed to Imam Hasan and said, 'This is the first of them,' and to Imam Husayn said, 'This is the second of them, and all the other Imams will be from among his descendants!'" 
Imam Ja'far al-Sadiq, peace be upon him, said:
"The books were kept by Ali. When he decided to make a journey to Iraq, he entrusted them to Umm Salamah. When he died, they were passed on to Imam Hasan, and from him to Imam Husayn. When he was martyred, they came into the possession of Ali b. Husayn, after which they were passed on to my father." 
Imam al-Baqir, peace be upon him, told Jabir:
"If we were to narrate traditions based on our own views, we would surely perish. Know that we narrate only traditions that we have stored up from the Messenger of God just as people store up silver and gold." 
The Commander of the Faithful, Ali, peace be Upon him, said:
"There is not a single verse in the Qur'an the time and place of the revelation of which are unknown to me. Abundant knowledge is stored in my breast, so ask me whatever you will before you lose me. Whenever a verse was revealed to the Prophet, peace and blessings be upon him and his family, and I happened not to be in his presence, he would wait until I arrived and then tell me,' Ali, some verses were revealed while you were gone,' and explain their interpretation to me." 
He also said:
"There are numerous sciences hidden in my breast, taught to me by the Messenger of God. If people were to be found with the capacity to learn and retain them, to transmit them accurately and faithfully, I would entrust some of those sciences to them, and open for them a door leading to one thousand other doors." 
Malik b. Anas says: "The Messenger of God told Ali, After I am gone, clarify whatever causes disagreement among people!'" 
There can be no doubt that this process of instruction did not take place by conventional or usual means, through the Messenger of God, peace and blessings be upon him and his family, opening up myriad gates of knowledge before Ali on the limited occasions that were available to him, thus making the treasury of his heart overflow with knowledge. The instruction was accomplished in a special way deriving from the power of prophethood and inner guidance inherent in prophethood; it was in this way that the heart of Ali, peace be upon him, became replete with the profound truths that his deep faith, wide-ranging intellect, and exalted vision fitted him to receive.
Salim b. Qays reports the Commander of the Faithful, Ali, peace be upon him, to have said:
"Not all the Companions of the Prophet, peace and blessings be upon him and his family, had the intellectual capacity to ask him concerning certain things, or to understand the answer he might give. Those who found it difficult to put their questions before the Prophet often preferred that someone else should do it on their behalf and obtain the necessary answers.
"I, however, was constantly in the company of the Prophet, day and night, and often I was alone with him. Whenever he went, I would accompany him. The Companions knew that no one had this relation with him except me. Sometimes he would come to our house, and sometimes I would meet him in one of his residences. Whenever I entered his presence, he would dismiss everyone else, even ordering his wives to leave the room. But when he came to our house, Fatimah, peace be upon her, and our children would remain in the room. I would pose my questions to him, and he would answer, and sometimes when I was silent, he would begin speaking. He recited for me all the verses of the Qur'an that were revealed to him, and I would write them down and record them in my own hand. He expounded for me the interpretation of the Qur'an, its abrogating and abrogated verses, its categorical and metaphorical verses, its specific and general verses. He would beseech God to grant me the power to retain and understand whatever he told me, and indeed I have not forgotten any part of the knowledge he conveyed to me. He instructed me in the permitted and the forbidden, God's commands and prohibitions, and the scriptures that had been revealed to preceding prophets, and I committed all of it to memory, not forgetting so much as a letter. Then he placed his blessed hand on my breast and besought God to fill my heart with knowledge, wisdom, understanding, and light.
"I then said to him, 'O Messenger of God, ever since you prayed for me, nothing has been effaced from my memory; do you fear that forgetfulness might overtake me?' He answered, 'I have no fear of ignorance or forgetfulness on your part, and my confidence in you is complete.'" 
It was the presence of such qualities in Ali, who attained the same loftiness of thought as the Prophet, that caused the Prophet to declare of him: "I am the city of knowledge, and Ali is its gate; whoever is desirous of knowledge must enter by that gate." 
In this utterance the Prophet is informing the ummah that whoever wishes to attain any part of his knowledge must seek the aid of Ali.
The Prophet also said in this connection: "O Ali, I am the city of knowledge, and you are the gate to that city. Anyone who imagines he can enter by other than that gate is in error." 
And again: "I am the house of wisdom and Ali is its door." 
Insofar as correct action depends on knowledge, it is incumbent on all Muslims to seek the knowledge and guidance of Ali in order for their deeds to be in conformity with the teachings of the Prophet.
The Messenger of God, peace and blessings be upon him and his family, being fully aware of the future needs of the Muslims, decided to entrust his knowledge to one who would be able to satisfy the religious needs of society after his death, and present God's commands and ordinances in uncorrupted form to all those who had recently become Muslim. He was therefore commanded by God to exert himself in the training and education of Ali, that enlightened one whose being concealed precious treasure of learning, who had the necessary qualities for guarding and preserving God's laws, and who had all the attributes requisite in a leader.
Ibn Abbas reports: "The Messenger of God used to say, 'When I readied myself to engage in intimate discourse with God, He would speak to me in turn. Whatever I learned from God Almighty, I taught to Ali, so Ali is the gate to my learning and knowledge.'" 
Imam Husayn b. Ali, peace be upon him, said: "When the verse, 'And We have everything plain for you in a clear book (imam)' (10:12) was revealed, the Companions asked the Prophet whether the book in question was the Torah or the Gospels. He answered, 'Neither.' And then, looking in the direction of my father he declared, 'This is an Imam the treasury of whose being God has caused to overflow with knowledge and learning.'" 
The Commander of the Faithful, Ali, peace be upon him, said:
"The Most Noble Messenger used to spend part of his time every year in the cave on Mount al-Hira', and no one would see him go there except me. At that time the only household that had accepted Islam was that of the Prophet himself, peace and blessings be upon him and his family, and Khadijah, with myself counting as the third member of their family. I could see in him the light of revelation and messengerhood and smell the scent of prophethood. When revelation came to the Prophet, I would hear the sound of Satan in my ear, and I would ask him, 'O Messenger of God, what is this sound?' He said, 'It is Satan, despairing of ever being worshipped. Ali, whatever I hear, you hear, and whatever I witness, you witness, the difference between us being that you are not a prophet but my support and a virtuous man.'" 
al-Tirmidhi reports the Messenger of God to have said regarding Ali.
"My God extend His favor to Ali and make him the pivot around which truth turns."
 al-Kulayni, al-Kafi,
Vol. I, p.225.
 Ibid., p.202.
 Ibid., p. 176.
 Ibid., p. 264.
 Ibid., p. 229.
 Ibid.., p. 61.
 Ibid., p. 61.
 Ibid., p. 63.
 al-Tabataba'i, al-Mizan,
Vol. III, p.74.
 al-Kulayni, al-Kafi,
Vol. I, p. 213.
 Ibid., p.241.
 al-Burujardi, Jami'
ahadith al-Shi'ah, Vol. I, p. 138.
 al-Qunduzi, Yanabi' al-Mawaddah,
 al-Burujardi, Jami'
ahadith al-Shi'ah, Vol. I, p. 141.
 Ibid., p. 130.
 al-Qunduzi, Yanabi' al-Mawaddah,
 al-Bahrani, Ghayat al-Maram,
 al-Muttaqi al-Hindi, Kanz
al-'Ummal, Vol. VI, p. 516; al-Hakim, al-Mustadrak, Vol. III, p.
 al-Kulayni, al-Kafi ,
Vol. I, p.64.
 al-Khwarazmi, al-Manaqib,
p. 40; al-Hakim, al-Mustadrak, Vol. III, p. 126; al-Khat.ib
al-Baghdadi, Tarikh Baghdad, Vol. IV, p.348; Ibn Hajar, al-Sawa'iq,
p. 73; Ibn al-Athir, Usud al-Ghabah, Vol. IV, p.22.
 al-Qunduzi, Yanabi' al-Mawaddah"
 al-Tirmidhi, Jami'
al-Sahih, Vol. XIII, p. 171; al-Muttaqi al-Hindi, Kanz al-'Ummal,
Vol. VI, p. 156; al-Isbahani, Hilyat al-Awliya', Vol. I, p.64.
 al-Qunduzi, Yanabi' al-Mawaddah,
 Ibid., p.77.
 al-Radi, Nahj al-Balaghah,
 al-Tirmidhi, Jami' al-Sahih, Vol. V, p.297.