Harut and Marut
They follow what the demons recited during Solomon's reign. Solomon believed, but the demons did not, teaching people sorcery and what had been sent down to Harut and Marut, the two angels in Babylon...(Qur'an, 2:102)
During the time of Prophet Solomon (pbuh), some people admired magical practices that God had forbidden. They learned such magic from demons and what was taught to two angels (Harut and Marut) in Babylon, again from demons, and used them for evil purposes.
Satan, who opposed Prophet Solomon (pbuh), placed certain individuals under his spell and may have used Prophet Solomon's (pbuh) great wealth to incite the people against him. They might have rebelled by establishing secret societies to undermine his kingdom. (God knows the truth.) As a matter of fact, historical sources say that Prophet Solomon's (pbuh) Muslim Israelite Kingdom was split in two after his death because of internal conflicts.
...Harut and Marut, the two angels in Babylon, who taught no one without first saying to him: "We are merely a trial and temptation, so do not abandon belief." People learned from them how to separate a man and his wife. But they cannot harm anyone by it, except with God's permission. They have learned what will harm them and will not benefit them. They know that any who deal in it will have no share in the Hereafter. What an evil thing they have sold themselves for. If they only knew! (Qur'an, 2:102)
In order to deceive human beings, demons taught them the magic that they learned from Harut and Marut. However, Harut and Marut told their potential students that they were a test from God and warned them against abandoning belief. Only after this warning did they teach the people. For this reason, people must realize that magic is better off avoided.
Everyone who resorts to magic must understand that only God can make it effective, for He created that particular spell for a purpose. No one can obtain anything without His knowledge and permission.
People who believe in magic may suffer because of it, for God rewards their deviation with misery.
Believers have no interest in magic or in what demons say. Using magic to destroy human relationships, as well as deviating from the right way by delving into such superstitious beliefs, are evil games designed by Satan to prevent people from following the right path. Those who practice magic and the like have been beguiled by Satan.
There is no room in the Qur'an for such superstitious beliefs, for:
Say: "I seek refuge with the Lord of Daybreak, from the evil of what He has created, from the evil of the darkness when it gathers, and from the evil of women who blow on knots…" (Qur'an, 113:1-4)
The same matter is spoken of in the verses mentioning Harut and Marut. Neither magic nor women who blow on knots have any power or efficacy, for only God, Lord of the Worlds, has true power. All believers rely on God and trust only in Him, hope for assistance from Him, tell Him all of their needs and anxieties, and take Him as their friend and guardian.
These verses may contain some reference to the End Times. In speaking of magic, God may be indicating that this sinful and useless practice might increase in the End Times. In fact, people might use them to earn a living and fortune-tellers might exploit people. One hadith mentions this situation:
The Hour will come when people will believe in the stars and reject Qadar [the Divine Decree of destiny]. (Ahmad Diya' ad-Din al-Kamushkhanawi an-Naqshbandi, Ramuz al-Ahadith, vol. 1, p. 1540.)