for Allah will see that his right is restored on the Day of Resurrection; Allah will never neglect him.
“They had already known that whoever purchased it would have no share in the Hereafter.” In this verse Allah emphasizes the point with both an oath and the emphatic particle lam. In other words, those who took up the study of sorcery were fully aware that whoever does so will have no portion in the Hereafter. How did they know? From the warning issued by the two angels: “We are only a trial, so do not disbelieve.” The matter was crystal-clear to them, yet—may Allah protect us—they still chose that path. Hence the wording “whoever purchased it,” for one only purchases something out of eagerness and desire for what is being bought; therefore Allah called the learning of magic a “purchase.”
“[He] will have no share in the Hereafter” means he will enjoy no portion at all in the next life. No human being is completely without a share in the Hereafter except the disbeliever. The believer does have a portion: he may enter Paradise without reckoning, or he may be punished in proportion to his sins and then end up in Paradise. The disbeliever, however, has no share whatsoever in the Hereafter.
“How wretched is that for which they sold themselves.” Here sharaw (“they sold”) means that they bartered away their own souls; Allah condemns what they chose and the price they paid for it. “If only they knew”—that is, had they possessed real knowledge, they would have realized that this is sheer evil.
To sum up: sorcery is among the major sins and can lead to outright disbelief. The legal punishment for the sorcerer is execution, whether or not his practice has rendered him a disbeliever, for the Prophet (peace and blessings be upon him) said, “The prescribed penalty for the sorcerer is that he be struck with the sword,” and in another wording, “a single blow with the sword.”
We ask Allah the Exalted to protect the Muslims from their harm, to turn their plots back against them, and to help us and you to learn the lawful litanies by which a servant shields himself from his enemies among both jinn and humankind. Allah is the One who grants success.