There are several distinctions between the miraculous gifts granted to Allah’s allies and the satanic states that resemble them.
One is that “the miraculous gifts granted to Allah’s allies” arise from faith and piety, whereas “satanic states” arise from what Allah and His Messenger have forbidden. Allah Most High says:
“Say, ‘My Lord has only forbidden immoral deeds, whether committed openly or secretly, sin, unjust aggression, associating with Allah that for which He has sent down no authority, and saying about Allah what you do not know.’”
Speaking about Allah without knowledge, associating partners with Him, wrongdoing, and immoral deeds have all been forbidden by Allah Most High and His Messenger. They therefore cannot be grounds for Allah Most High to honor someone with miraculous gifts. Thus, if such phenomena do not occur through prayer, remembrance of Allah, and recitation of the Quran, but instead occur through what Satan loves and through practices involving the association of partners with Allah, such as seeking aid from created beings—or if they are used to wrong others and commit immoral deeds—then they are satanic states, not miraculous gifts from the Most Merciful.
Among these people are those whose devil descends upon them when they attend a gathering of whistling and clapping, until it carries them through the air and takes them out of that house. If one of Allah Most High’s allies arrives, he drives the devil away, and the person falls. This has happened to more than one person.
Among these people are those who seek aid from a created being, living or dead, whether that living person is a Muslim, a Christian, or a polytheist. The devil then assumes the form of the person whose aid is sought