Praise be to Allah.
Firstly:
This hadith was narrated by Imam Ahmad from Wabisah ibn Ma`bad (may Allah be pleased with him), that the Prophet (blessings and peace of Allah be upon him) said to him: “Have you come to ask me about righteousness and sin?” He said: Yes. The Prophet (blessings and peace of Allah be upon him) put his fingers together and started poking me in the chest with them and saying: “O Wabisah, consult your heart and see how you feel about it” – three times –; “Righteousness is what you feel at ease with, and sin is what you feel uneasy with and feel hesitant about, regardless of what people advise you.”
This is one of the Forty Hadiths of an-Nawawi. An-Nawawi, al-Mundhiri and ash-Shawkani classed it as sound (hasan); and al-Albani classed it as sound (hasan) because of corroborating evidence in Sahih at-Targhib (1734).
There are other hadiths which indicate the same meaning as the hadith of Wabisah. It was narrated from an-Nawwas ibn Sam`an (may Allah be pleased with him) that the Prophet (blessings and peace of Allah be upon him) said: “Righteousness is a good attitude, and sin is that which wavers in your heart and you do not want the people to find out about it.”
It was narrated that Abu Tha`labah al-Khushani (may Allah be pleased with him) said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “Righteousness is that with which the heart feels at ease and comfortable, and sin is that with which the heart does not feel at ease or comfortable, regardless of what people advise you.” Narrated by Ahmad (29/278-279 – Mu’sasat ar-Risalah edn.); classed as authentic (sahih) by the commentators under the supervision of Shaykh Shu`ayb al-Arna’ut. Al-Mundhiri said: Its isnad is good (jayyid).
End quote from At-Targhib wat-Tarhib (3/23).
Al-Hafiz Ibn Hajar said something similar in Jami` al-`Ulum wal-Hikam (1/251), as did al-Albani in Sahih at-Targhib (2/151).
Secondly:
Many people misunderstand this hadith, as they take it as a basis for deeming something to be halal or haram, according to their whims and desires. Thus they commit unlawful deeds and quote the hadith: “Consult your heart and see how you feel about it”! even though the hadith is not intended be interpreted in this way; rather what the hadith means is that the believer whose heart is pure may ask someone about something and be told that it is halal, but the believer does not feel at ease with doing it. In this case, he must refrain from doing it, on the basis of what his heart is telling him.
Ibn al-Qayyim (may Allah have mercy on him) said:
It is not permissible to act on the basis of a fatwa if you feel reluctant and hesitant about it, because the Prophet (blessings and peace of Allah be upon him) said: “Consult your heart, regardless of what people advise you.”
So you should see how you feel first, because a fatwa received from a mufti will not absolve you before Allah if you know that in reality the issue is different from the fatwa he issued. Similarly, the judgement of a judge in your favour will not benefit you, because the Prophet (blessings and peace of Allah be upon him) said: “If I issue a judgement in someone’s favour that allows him to take something that belongs rightfully to his brother, let him not take it, for I have only allocated to him a piece of fire.”
The mufti and the judge are the same in this regard, and the one who seeks a fatwa should not think, just because there is a fatwa from a scholar to that effect, that what he asked about is permissible for him, when he knows that in reality what is right is different from the fatwa, whether he felt uneasy in his heart about it because he was aware of the true nature of the matter that he asked about, or because he was uncertain about it or knew nothing about it, or he was aware of the mufti’s ignorance, or that the mufti tries to give fatwas that suit people, or he does not base his fatwas strictly on the Quran and Sunnah, or he is known for giving fatwas based on loopholes and concessions that are contrary to the Sunnah, and other reasons not to trust his fatwa of feel at ease with it.
End quote from I`lam al-Muwaqqi`in (4/254).
Shaykh Ibn `Uthaymin (may Allah have mercy on him) said:
That is, even if someone gives you a fatwa saying that this is permissible, but you do not feel at ease with it or comfortable with it, then do not do it, because that is a sign of goodness and righteousness, unless you are a person who suffers from intrusive thoughts, doubts and hesitation, in which case you should not pay attention to that. The Prophet (blessings and peace of Allah be upon him) only addressed this advice to people who are pure in heart and have no ill intentions.
End quote from Sharh Riyadh as-Salihin (2/248).
The one who may consult his heart and see how he feels is the one who has a pure heart, not the one whose heart is deviated, because if the one whose heart is deviated consults his heart about grievous and major sins, he will decide that they are permissible, with no ambiguity about that.
Regarding this, Shaykh Muhammad ibn `Uthaymin (may Allah have mercy on him) said: “sin is that which wavers in your heart” means: you are hesitant and anxious about it; “and you do not want the people to find out about it” means: because it is blameworthy and shameful, so you find yourself hesitant to do it and not wanting people to find out about it.
This advice is addressed only to one whose heart is pure and sound, for he is the one who will feel unease about that action that is sinful, and he will not like people to find out about it.
As for rebellious people who do not obey Allah and whose hearts have grown hard, they do not care; rather they may boast about committing evil and sin. Therefore these words do not apply to everyone; rather they apply only to those who are pure and sound in heart, for if such a person thinks of committing a sin, even if he is not aware that it is a sin according to Islamic teachings, you will find him hesitant and not wanting people to find out about it. This is a sign that it is a sin, as the believer feels uneasy in his heart about it.
End quote from Sharh al-Arba`in an-Nawawiyyah (p. 294, 295).
And Allah knows best.