The Ruling on Countering Magic with Magic
Question:
I have a friend whose wife was subjected to magic and no medicine has helped her. So another person pointed out a man to us who treats magic with magic... is this man guilty of any sin, since he is using magic in order to benefit others and he is not harming anyone by it? And is there any sin upon my friend for going to this magician in order to cure his wife from what is afflicting her?
Answer:
I would like to make clear that magic is one of the major sins; indeed, it is Kufr if the magician seeks help from the devils or commits Shirk thereby. Teaching magic is also Kufr and it is incumbent to avoid it and beware of it so one does not fall victim to the kind of Kufr which takes one out of the fold of Islam. As for removing the spell of one affected by magic, it may be divided into two categories. The first category is through the use of permitted invocations from the Qur'an; this is allowed and there is no objection to it. One of the best things to be recited against magic is:
Say: "I seek refuge with the Lord of the daybreak."
Say: "I seek refuge with the Lord of mankind."
The second category is curing magic by magic; in this matter there is a difference of opinion, both among the early scholars and later scholars. Some of them permit it because of the removal of evil entailed in it for the one who is under its spell and others have forbidden it. The Prophet was asked about An-Nushrah and he said:
It is from the deeds of Satan.
And the deeds of Satan are those which contain magic. As for that which uses permitted invocations, there is neither objection nor opposition to it, until such times as Allah cures him of that (which ails him). As for belief in magic, it is of two types: The first is that one believes that it has an effect, and there is no objection to this, because it is a matter of fact. The second type is to believe in it and to accept it; this is forbidden and not permitted.
Source:
Ibn 'Uthaimin
Fatawa Islamiyah, Vol. 1 Pages 18-19