THE THIRD FOUNDATION:
Sincerity in seeking knowledge is a condition that is continuous and not just preliminary:
What this means is that the student of knowledge should continually strive to implement sincerity in himself, and that he should not refrain from his studies due to the claim that he did not achieve sincerity.
Some scholars have provided the following definition for sincerity (ikhlaas): Ibn Jamaa’ah said:
“It means that one has a good intention when seeking knowledge, by intending through his studies to please Allaah, to act in accordance with what he learns, to revive the Sharee’ah (Islamic legislation), to illuminate his heart, to elucidate its (i.e. knowledge’s) hidden meanings; to get near to Allaah on the Day of Judgement, and to subject oneself to what Allaah has prepared for those who possess it, such as His Contentment and great virtue.”
Sufyaan Ath-Thawree, may Allaah have mercy on him, said:
“I did not try to rectify anything that was more difficult upon me than my intention.”
One should not intend, by his search for knowledge, to fulfil some worldly goal such as assuming leadership, gaining status and wealth, competing with colleagues, having people extol him, taking the front seat in a gathering, and so on, since he will be exchanging that which is better for that which is lower.
Abu Yoosuf, may Allaah have mercy on him, said:
“Intend Allaah through your (search for) knowledge, for indeed I never sat in a gathering of people in which I made it my intention to humble myself except that I didn’t leave from it until I had surpassed them. And I never sat in a gathering of people in which I made it my intention to surpass them, except that I didn’t leave from it until I was disgraced.
Knowledge is one of the many acts of worship and one of the many ways of gaining nearness to Allaah. So if one purifies his intention while seeking it, his deed will be accepted and purified. And its blessing will become complete. However, if he intends other than the sake of Allaah when seeking knowledge, his deed becomes nullified and wasted and his transaction is lost. Perhaps he may even miss out on these (worldly) objectives and never achieve any of them. So in this case, he will have failed in his objective and at the same time wasted his efforts.” 
* This principle entails several matters, the most important of which is:
The Devil enters into the hearts of some people desiring to turn them away from knowledge based on the argument that one should leave off seeking knowledge until he first purifies his intention. This is a plot, scheme and deception of the Devil. Rather, it is upon a Muslim to continue and persevere in his search for knowledge, and to constantly re-evaluate his intention, as Sufyaan Ath-Thawree said: “I did not try to rectify anything that was more difficult upon me than my intention.”
And this is Sufyaan we are talking about, so it applies even more so for those other than him!! Therefore, one should not make this into something that diverts him away from seeking knowledge.
When Hishaam Ad-Dustawaa’ee, may Allaah have mercy on him, said;
“By Allaah, I cannot (honestly) say that I ever went out one day to seek hadeeth for the sake of Allaah”, Adh- Dhahabee, may Allaah have mercy on him, commented on this saying: “By Allaah, me either!”
The Salaf would seek knowledge for the sake of Allaah, and so they became dignified and went on to become Imaams that were followed and looked up to by the people. And there were other people from among them who did not seek knowledge for the sake of Allaah at first, but yet they still attained the knowledge, then they woke up and examined themselves. And so the knowledge led them to have sincerity while on their path (of seeking knowledge). This becomes clearer in what was stated by Mujaahid and others: “We sought this knowledge while not having a big intention concerning it. Then Allaah granted us the intention (for it) afterward.”
Others would say: “We sought this knowledge for other than the sake of Allaah. But the knowledge refused that it should be sought except for the sake of Allaah.” So this is also good.Then, afterwards, they went on to spread the knowledge with righteous intentions.
And there were other people that sought knowledge with corrupt intentions – for the sake of the worldly life and so that they could be praised by the people. So they got what they intended.
The Prophet (Sall Allaahu alaihi wa Sallam) said: “Whoever fights in battle with the intention of (getting) war booty, he will have what he intends.”
You will find this type of people not being illuminated by the light of knowledge. The knowledge has no impact on their souls nor does it produce a noticeable result in their actions. Rather, the one with knowledge is only he who fears Allaah.
Then there were other people that attained knowledge and achieved positions due to it, but they oppressed people and abandoned the requisites of knowledge, thus embarking on committing major sins and lewd acts!! So woe be to them – these people are not scholars.
Some other people do not fear Allaah with regard to their knowledge, but rather engage in schemes, issuing verdicts permitting prohibited matters and reporting unauthentic and irregular narrations.
Other people show audacity before Allaah and fabricate ahaadeeth, so Allaah exposed them and their knowledge left them. So their preparation became only for the Hellfire.
All of these types of people took in a large portion of knowledge, and they excelled in it, in the general sense. Then they were succeeded by later generations that had deficiency in knowledge and action. Then there followed a people after that who ascribed themselves to knowledge outwardly but were not well-versed in it, with the exception of a few among them who thought that because of that they had become noble scholars. However, it did not cross their minds that they were gaining nearness to Allaah through it.
The reason for this is because they did not experience any teacher that was taken as a role model with regard to knowledge. So they became like savage barbarians. The biggest aim of one of their teachers was to obtain and amass costly books which they could look into on any given day. So they would misinterpret what was stated therein and not agree with it. We ask Allaah for salvation and pardon.
Some of them have stated: “I am not a scholar, nor have I seen a scholar.” 
This third foundation is from amongst the important principles – and it is that a student strives to make his intention purely for the sake of Allaah when seeking knowledge. Achieving sincerity is something necessary. Allaah says:
وَمَا أُمِرُوا إِلَّا لِيَعْبُدُوا اللَّهَ مُخْلِصِينَ لَهُ الدِّينَ
“And they were commanded not except to worship Allaah sincerely, making the worship purely for His sake.” [Surah Al-Bayyinah: 5}
As we mentioned before, seeking the religious knowledge that is required in order to properly worship Allaah is itself an act of worship and part of the implementation of Laa Ilaaha IllaaAllaah. So in summary, seeking knowledge is an act of worship that one must strive to have sincerity in whilst performing it. The Messenger of Allaah (Sall Allaahu alaihi wa Sallam) said: “Verily, actions are based on intentions. And verily, every man will have what he intends.” 
Based on this, we say: A student of knowledge must continuously strive to correct his intention and to make it purely for the sake of Allaah.
Someone may say: “Does this mean that I should not seek knowledge until I (first) correct my intention?”
I say: No. Rather, you should seek knowledge. But while you are seeking knowledge, you should examine yourself and rectify yourself by way of correcting your intention. If this person continues, saying: “I want to leave off seeking knowledge until I (first) correct my
I will reply by saying: This is a trap from the Devil. He has opened up for you one of the doors of good intending by that to turn you away from that which is better and greater. So therefore, you should continue and be perseverant in your search for knowledge. And you should continuously rectify yourself, for indeed your knowledge – Allaah-willing – will guide you to make your intention sincerely for the sake of Allaah.
The Salaf would say: “We sought this knowledge for other than the sake of Allaah. But the knowledge refused that it should be sought except for the sake of Allaah.”
 Tadhkirat-us-Saami’ wal-Mutakallim (pg. 69-70)
 Siyar A’laam an-Nubalaa (7/152-153)
 Al-Bukhaaree reported this hadeeth in his Saheeh: Book of the Beginning of Revelation (no. 1) on the authority of Umar bin Al-Khattaab (radhi Allaahu anhu) and Muslim in his Saheeh: Book of Leadership (no. 1907)
Source : Laying the Foundations For Seeking Knowledge
Written by: Shaikh Muhammad bin ‘Umar bin Saalim Baazmool
Translated by: isma’eel alarcon, Published by al-ibaanah.com