In ‘بریقہ محمودیہ شرح طریقہ محمدیہ’, a great Faqeeh Sayyiduna Abu Sa’eed Muhammad Bin Muhammad Bin Mustafa Bin ‘Usman Khaadmi Hanafi رَحْمَۃُاللہِ تَعَالٰی عَلَیْہ (passed away in 1176 AH) has written: There are five types of thoughts of sin which come to the heart:
1 ‘ھَاجِس’ [Haajis] the thought that comes to the heart
2 ‘خَاطِر’ [Khaatir] the thought that comes to the heart repeatedly
3 ‘حَدِیْثِ نَفْس’ [Hadees-e-Nafs] means there is a doubt in the heart as to whether that act should be carried out or not
4 ‘ھَمّ’ [Hamm] means the thought of carrying out that act overcomes [your heart]
5 ‘عَزْم’ [‘Azm] means the thought of carrying out that act becomes further strong, but not confirmed.
Rulings on them
There is a consensus among all that there is no accountability for ‘ھَاجِس’ [Haajis] because it is impossible to stay safe from it. After it, there is ‘Khaatir’ which a person can remove because he can deflect attention away from the evil as its thought comes to mind. ‘Khaatir’ and ‘Hadees-e-Nafs’ are exempted due to the blessed Hadees. When ‘Hadees-e-Nafs’ is exempted, the thoughts which have been mentioned before it are more exempted.
Thought of virtuous deed
If these three types of thoughts [i.e. Haajis, Khaatir and Hadees-e-Nafs] are about virtue, so one cannot get Sawab [reward] for them due to not having the intention to perform a virtuous deed. Anyhow, when ‘ھَمّ’ [Hamm] is about a virtue, a virtue will be written and if it is about a sin, a sin will not be written. Then if he refrains from sin for the pleasure of Allah Almighty, virtue will be written and if he commits a sin, only one sin will be written, whereas there is accountability for ‘عَزْم’ [‘Azm]. (Bareeqah Mahmoodiyah fi Sharh Tareeqah Muhammadiyyah, vol. 2, pp. 141)
Example of thoughts relating to heart
These five types can be understood by this example. If this thought comes to someone’s heart that he should commit a theft, this thought is ‘Haajis’. If this thought comes repeatedly, it is ‘Khaatir’. When he turns towards theft and makes this plan that he has to steal from such and such a house, break its such and such a wall, return through such and such a route, etc., so it is ‘Hadees-e-Nafs’. When he has intended to commit a theft and the intention to commit the theft dominates but he has a little presumption too that he might get caught and therefore he feels that it is better for him not to commit the theft, it is ‘Hamm’. When this little presumption is also dispelled, and he makes a firm intention that he will surely commit the theft even if he is caught, it is ‘Azm’. There is no accountability in the first four types, whereas there is accountability for the fifth type, i.e. ‘Azm’, though he does not act upon his ‘Azm’ due to any reason. For example, if he enters a house with the intention of theft, but he discovers that there is nothing there, therefore he returns, so now he will get the sin of [committing] theft because he had made a firm intention to commit the theft. If there had been valuables, he must have stolen [them].
Making intention to perform a virtuous deed is also a virtue
It is also stated in a long blessed Hadees of Sahih Muslim that [Allah Almighty has stated]:
مَنْ ھَمَّ بِحَسَنَةٍ فَلَمْ یَعْمَلْھَا کُتِبَتْ لہُ حَسَنَةً فَإِنْ عَمِلَھَا کُتِبَتْ لَہُ عَشْرًا
وَمَنْ ھَمَّ بِسَیِّئَةٍ فَلَمْ یَعْمَلْھَا لَمْ تُکْتَبْ شَیْئًا، فَإِنْ عَمِلَھَا کُتِبَتْ سَیِّئَةً وَاحِدَۃً
Whoever intends to do any virtuous deed, [but] then he does not do the virtuous deed so a virtue will be written for him. Then if he does it, ten [virtues] will be written for him and whoever intends [to commit] a sin, then he does not commit, so nothing will be written for him. Then if he commits [it], so for him only one sin will be written. (Sahih Muslim, pp. 87, Hadees 411)
Regarding this blessed Hadees Mufti Ahmad Yar Khan رَحْمَۃُاللہِ تَعَالٰی عَلَیْہ has said: ‘ھَمّ’ [Hamm] means a weak intention, that is to say, one virtue will even be written in the Book of Deed of the one who makes a weak intention to perform a virtuous deed, though he does not perform it due to any Shar’i reason or any apparent reason. For example, if someone makes an intention for Hajj, but his name is not chosen by a lot so he will get the Sawab for his intention as it is also a virtue to make intention for a virtuous deed or rather desire to perform a virtuous deed is also a virtue.
For example, if Hujjaj are going for Hajj, seeing them a poor person sheds tears on the state of his being deprived and expresses this wish, ‘If I had money, I would also go [for Hajj]’, he will get the Sawab. A person is pondering over the good luck of blessed companions رَضِىَ الـلّٰـهُ تَعَالٰی عَـنْهُم by thinking that they were very fortunate as they were blessed with the blessed Deedar [sight] of the Beloved Rasool صَلَّی اللہُ تَعَالٰی عَلَیْہِ وَاٰلِہٖ وَسَلَّمَand thought that
Jo ham bhi waan hotay khaak-e-gulshan lipat kay qadmaun say laytay utran
Magar karayn kya naseeb mayn to yeh na-muradi kay din likhay thay
He is getting Sawab for this wish and اِنْ شَآءَ اللہ عَزَّوَجَلَّ tomorrow he will be raised with blessed companions رَضِىَ الـلّٰـهُ تَعَالٰی عَـنْهُم. Commenting on ‘for him ten virtues will be written’ blessed Mufti has written: i.e. the intention for a virtuous deed is one virtue and to do the virtuous deed is [equal to] ten virtues. It is the blessing of Allah Almighty, and then there is separate Swab for every virtuous deed. [For example], making intention for Salah is a separate virtue, making Wudu is a separate virtue, walking to the Masjid is a separate virtue or rather every step is a separate virtue, sitting there in order to wait for the Salah is another virtue, making Du’a after Salah is another virtue. Salah is a permanent separate virtue. We work according to our capacity and He عَزَّوَجَلَّ bestows upon us as per His Glory.
He رَحْمَۃُاللہِ تَعَالٰی عَلَیْہ has further said: There is a difference between ‘Hamm’ and ‘Azm’. ‘Hamm’ means ‘the thought of sin’; it is not a sin, in fact, to refrain from it and make repentance is a virtue. (Mirat-ul-Manajeeh, vol. 8, pp. 151, 152)
Ik dil hamara kya hay aazaar is ka kitna
Tum nay to chaltay phirtay murday jila diye hayn
(Hadaiq-e-Bakhshish, pp. 101)
 The Beloved Rasool صَلَّی اللہُ تَعَالٰی عَلَیْہِ وَاٰلِہٖ وَسَلَّمَ has said: The evil thoughts which come to the heart of my Ummah, Allah Almighty forgives them until they act upon them or use them in their conversation. (Sahih Bukhari, vol. 2, pp. 153, Hadees 2528)