Human beings are continually forming intentions and acting. Thus, if a person’s intentions and actions are not directed toward what Allah and His Messenger—may Allah bless him and grant him peace—love, they are directed toward what Allah and His Messenger—may Allah bless him and grant him peace—do not love.
Spiritual states result from deeds, so what these people experience corresponds to their deeds. Often a person imagines things that he believes exist externally, although they exist only within himself. He hears speech that comes from Satan or from himself, believing it to be from Allah Most High. One of them may even believe that he sees Allah with his own eyes and hears His speech with his own ears, coming from outside himself, just as Moses son of Imrān heard it. For some, what they see are devils, and what they hear is their speech, yet they believe this to be among the miraculous gifts granted to Allah’s righteous servants. This is a broad subject, discussed in detail elsewhere.
For this reason, the Prophet—may Allah bless him and grant him peace—said in an authentic hadith:
“Dreams are of three kinds: a dream from Allah; a dream through which Satan causes distress; and a dream arising from what a person thinks about while awake and then sees in his sleep.”