Will a person be brought to account for whatever crosses his mind of good or evil?
Question

Sometimes a person suffers from thinking of some sin, and other thoughts that come from the whispers of the Shaytaan and the nafs. Will he be requited for whatever crosses his mind, and will it be written in his record, whether it is good or bad?
Praise be to Allah.Al-Bukhaari (6491) and Muslim (131) narrated from Ibn ‘Abbaas (may Allah be pleased with him) that the Prophet (blessings and peace of Allah be upon him) said, relating from his Lord, may He be glorified and exalted: “Allah decreed good deeds and bad deeds, then He explained that. Whoever thinks of doing a good deed then does not do it, Allah will write it down as one complete good deed. If he thinks of doing a good deed and then does it, Allah [may He be glorified and exalted] will write it down between ten and seven hundred fold, or many more. If he thinks of doing a bad deed then he does not do it, Allah will write it down as one complete good deed, and if he thinks of it then does it, Allah will write it down as one bad deed.” 
Al-Bukhaari (5269) and Muslim (127) also narrated from Abu Hurayrah (may Allah be pleased with him), that the Prophet (blessings and peace of Allah be upon him) said: “Allah, may He be glorified and exalted, will forgive my ummah for whatever crosses their minds so long as they do not act upon it or speak of it.” 
Ibn Rajab (may Allah have mercy on him) said: 
These texts refer to four matters: the recording of good deeds and bad deeds, and thinking of good deeds and bad deeds. This is four matters.  
Then he said: 
… The third matter: thinking of good deeds. It is recorded as one complete good deed even if he does not do it, as it says in the hadeeth of Ibn ‘Abbaas and elsewhere. … In the hadeeth of Khuraym ibn Faatik it says: “… If a person thinks of doing a good deed but then does not do it and Allah knows that he thought of it and was keen to do it, He records for him one good deed…” [Narrated by Ahmad, 18556. al-Arna’oot said: Its isnaad is hasan. It was mentioned by al-Albaani in as-Saheehah]. This indicates that what is meant by “thinking of” here is the determination and resolve that are usually present when one is keen to do an action, not merely a passing thought that is not accompanied by any resolve or determination. 
Abu’d-Darda’ said: If a person goes to his bed, intending to pray during the night (qiyaam), then sleep overtakes him until morning comes, what he intended to do will be recorded for him. 
It was narrated that Sa‘eed ibn al-Musayyab said: If a person thinks of praying, fasting, going for Hajj or ‘Umrah, or going for jihad, then he is prevented from doing that, Allah will grant him the reward of what he wanted to do. 
Abu ‘Imraan al-Jawni said: It is said to the angel: Record such and such for So and so. He says: O Lord, he did not do it. He says: He intended it. 
Zayd ibn Aslam said: A man used to go around among the scholars, saying: Who will tell me of a deed that I may keep doing for Allah, for I do not like any hour of the day or night to come to me except I am striving for the sake of Allah, may He be exalted. It was said to him: You have found what you are looking for. Do good as much as you are able to, then when you become tired or you stop doing it, think about doing it, for the one who thinks about doing a good deed is like the one who does it. 
If the intention is accompanied by words or effort, the reward is ensured and the one who intended it is like the one who does it, as Abu Kabshah narrated that the Prophet (blessings and peace of Allah be upon him) said:
“[People] in this world are of four types: a person to whom Allah grants wealth and knowledge, so he fears his Lord with regard to it, upholds his ties of kinship with it, and acknowledges the rights of Allah concerning it – he is of the highest status. (The second is) a person to whom Allah grants knowledge but He does not grant him wealth, so he is sincere in his intention and says: If I had wealth, I would do the same as So and so does. He will be rewarded according to his intention and their reward will be the same. (The third type) is a person to whom Allah grants wealth, but He does not grant him knowledge, so he squanders his wealth without knowledge; he does not fear his Lord concerning it, he does not uphold his ties of kinship with it and he does not acknowledge the rights of Allah concerning it – he is of the worst status. (And the fourth type is) a person to whom Allah does not grant either wealth or knowledge, so he says: If I had wealth, I would do the same as So and so does. He will be requited according to his intention and their burden of sin will be the same.”
Narrated by Imam Ahmad, at-Tirmidhi and Ibn Maajah. Classed as saheeh by al-Albaani because of corroborating evidence. 
The phrase “Their reward will be the same” is understood as meaning that they are equal with regard to the basic reward for actions, but not with regard to the multiplication of that reward. Multiplication of reward is only for the one who actually does a deed, not the one who intends it but does not do it. If they were equal in all regards, a tenfold reward would be recorded for the one who thought of a good deed but did not do it, and this is contrary to all the texts. That is indicated by the verse in which Allah, may He be exalted, says (interpretation of the meaning): “Allah has preferred in grades those who strive hard and fight with their wealth and their lives above those who sit (at home). Unto each, Allah has promised good (Paradise), but Allah has preferred those who strive hard and fight, above those who sit (at home) by a huge reward” [an-Nisa’ 4:95]. Ibn ‘Abbaas and others said: Those who sit (at home), above whom those who strive hard and fight are preferred in grades are those who have excuses, and those who sit (at home), above whom those who strive hard and fight are preferred by a huge reward, are those who do not have excuses. 
Then he (may Allah have mercy on him) said: 
The fourth matter is thinking of evil deeds without doing them. In the hadeeth of Ibn ‘Abbaas it says that this will be recorded as one complete good deed. Similarly in the hadeeth of Abu Hurayrah, Anas and others it says that it will be recorded as a hasanah (good deed). In the hadeeth of Abu Hurayrah it says “for he gave it up for My sake” (Muslim, 129). This indicates that what is meant is that if a person was able to do what he thought of of sin, but gave it up for the sake of Allah, may He be exalted, one good deed will undoubtedly be recorded for him for that, because his refraining from committing that sin for that reason is a righteous deed. 
But if he thinks of committing a sin, then does not do it for fear of other people, or in order to show off to them, then it was said that he will be punished for refraining from it with that intention, because giving precedence to fear of people over fear of Allah is haraam, just as aiming to show off to people is also haraam. If refraining from the sin is accompanied by such intentions, then he will be punished for refraining. 
Al-Fudayl ibn ‘Iyaad said: They used to say: Refraining from doing something for the sake of people is showing off and doing it for their sake is shirk. 
But if he tries to do it by all available means then is prevented from doing it because it is not decreed that he should do it, in that case a number of scholars stated that he will be punished for it, because of the hadeeth, “… so long as he does not speak of it or act upon it.” So if a person strives to commit a sin, then is unable to do it, he has acted upon it. Similarly, the Prophet (blessings and peace of Allah be upon him) said: “When two Muslims confront one another with their swords, the slayer and the slain will both be in Hell.” I said – or it was said – O Messenger of Allah, (we understand about) the slayer, but what about the slain? He said: “He wanted to kill his companion.” (Narrated by al-Bukhaari, 31: Muslim, 2888). The words “so long as he does not speak of it or act upon it” indicate that if the one who thinks of a sin speaks of what he was thinking of, then he will be punished for thinking of it in that case, because he has committed a sin with his physical faculties, which is speaking with his tongue. That is also indicated by the hadeeth of Abu Kabshah quoted above, who said: (The fourth type of person) says: “If I had wealth, I would do with it what So and so does”, referring to the one who disobeyed Allah with his wealth. He said: “Their burden of sin will be the same.” 
Then he (may Allah have mercy on him) said: 
But if he changes his intention and gives up his resolve for no reason, will he be punished for what he thought of of sin, or not? 
There are two scenarios: 
The first is if his thinking of sin was a passing thought that he did not dwell on and it did not take root in his heart; rather he disliked it and was put off by it. This will be forgiven; it is like the awful thoughts or whispers that the Prophet (blessings and peace of Allah be upon him) was asked about, and he said: “That is clear faith.” [Narrated by Muslim, 132] 
When the verse (interpretation of the meaning) “…whether you disclose what is in your ownselves or conceal it, Allah will call you to account for it. Then He forgives whom He wills and punishes whom He wills…” [al-Baqarah 2:284] was revealed, that was distressing for the Muslims and they thought that it included these passing thoughts. Then the following verse was revealed, in which it says (interpretation of the meaning): “Put not on us a burden greater than we have strength to bear” [al-Baqarah 2:286]. (Narrated by Muslim, 126). This proved that with regard to that which they had no strength to bear, they would not be punished or brought to account for it, and it became clear that what was meant in the first verse was things that they resolved and intended to do. 
The second scenario is things that one has resolved and intends to do, that occurred to one’s mind and become established, and one dwells on them. These are of two types: 
(i)Acts of the heart (that have to do with belief), such as doubting or disbelieving in the Oneness of Allah, or Prophethood, or the Prophet’s mission, and other kinds of disbelief and hypocrisy. These are all things for which a person will be punished and by means of which he becomes a disbeliever and a hypocrite.
We may add to these all sins that have to do with the heart, such as loving that which Allah hates, hating that which Allah loves, arrogance, self admiration, etc. 
(ii)The second type has to do with that which is not actions of the heart; rather they are physical actions, such as zina, stealing, drinking alcohol, murder, slander and so on. If a person persists in wanting to do such things and resolving to do them, but he shows no outward indication of that, then there are two well-known scholarly views as to whether he will be held accountable for that.
The first view is that he will be held accountable for it. Ibn al-Mubaarak said: I asked Sufyaan ath-Thawri: Will a person be held accountable for thinking (of committing a sin)? He said: If he has resolved to do it, he will be held accountable. This view was regarded as more correct by many of the fuqaha’, scholars of hadeeth and scholars of kalaam among our companions and others. They quoted as evidence for that verses such as the following (interpretation of the meaning):
“And know that Allah knows what is in your minds, so fear Him”
[al-Baqarah 2:235]
“but He will call you to account for that which your hearts have earned”
[al-Baqarah 2:225]. 
(They also quoted as evidence) hadeeths such as that in which the Prophet (blessings and peace of Allah be upon him) said: “Sin is that which wavers in your heart and you do not want the people to find out about it” (narrated by Muslim, 2553). They interpreted the hadeeth “Allah, may He be glorified and exalted, will forgive my ummah for whatever crosses their minds so long as they do not act upon it or speak of it” as referring to passing thoughts and they said: Whatever a person dwells on and it takes root in his heart is included in what he earns and does, so it is not included in this hadeeth. 
The second view is that he will not be held accountable for mere intentions in all cases. This view is attributed to ash-Shaafa‘i and is also the view of Ibn Haamid among our companions, based on general meanings. Al-‘Awfi narrated from Ibn ‘Abbaas something which is indicative of the same view…
End quote from Jaami‘ al-‘Uloom wa’l-Hikam, commentary on hadeeth no 37 (2/343-353). 
To sum up: 
If a person thinks of doing a good deed, and it takes root in his heart and he resolves to do that, what he intended to do will be recorded for him, even if he does not do it, although the reward for the one who does do it is better and greater. 
If a person thinks of doing a bad deed, then refrains from it for the sake of Allah, one complete good deed will be recorded for him. 
If a person thinks of doing a bad deed, then refrains from it for the sake of people, or he tries to do it but is prevented from doing so, one bad deed will be recorded against him. 
If a person thinks of doing it, then he changes his intention after having intended it, if it was only a passing thought he will not be held accountable for it, but if it was one of the deeds of the heart that had nothing to do with physical actions (i.e., it has to do with belief), then he will be held accountable for it. If it was a physical action and he persisted in thinking of it and resolved to do it, then the majority of scholars are of the view that he will be held accountable for it. 
An-Nawawi (may Allah have mercy on him) said, after quoting al-Baaqillaani’s opinion that the individual will be held accountable in this case: 
Al-Qaadi ‘Iyaad (may Allah have mercy on him) said: The majority of the early generation and the scholars, including the fuqaha’ and the muhadditheen, are of the same view as al-Qaadi Abu Bakr, because of the hadeeths which indicate that people will be held accountable for actions of the heart (i.e., that have to do with beliefs). 
But they said: This resolve will be recorded as one bad deed, and it is not the bad deed that the individual thought of, because he did not do it and he refrained from it for a reason other than fear of Allah. But persisting and resolving in and of itself is a sin, so it will be recorded as a sin, and if he does it, it will be recorded as a second sin. But if he refrains from it for fear of Allah, may He be exalted, it will be recorded as a good deed, as it says in the hadeeth, “for he gave it up for My sake”, thus his giving it up out of fear of Allah, may He be exalted, his striving to overcome his nafs that is inclined towards evil, and his going against his whims and desires is in fact a good deed. The type of thinking of an action that is not to be recorded against the individual is the passing thought that does not take root in the heart and is not accompanied by intention or resolve.
End quote from Sharh Muslim, 2/151 
Ibn Rajab (may Allah have mercy on him) favoured the view that (when a person commits a sin), it will only be recorded as one sin, without any multiplication, so the punishment is for the sin, and thinking of it is not added to it, because if thinking of it were added to the sin, the individual would be punished twice for committing one sin. We cannot say that this may also be applicable to good deeds and that one does a good deed after thinking of it, he should be rewarded for the good deed but not for thinking of it. We say that this is not correct, because if a person does a good deed, a tenfold reward will be recorded for him, and it may be that some of that is as a reward for thinking of doing the good deed. And Allah knows best. End quote. 
And Allah knows best.