In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
2- But if the word of divorce was uttered with understanding and awareness of the ramifications of divorce, and what it would lead to of separation, then it does count as such.
Answering your question, Sheikh `Abdullah ibn Jibreen, the late prominent Saudi Muslim scholar, stated:
If the magic overwhelmed one’s reason to the point that he would be classed as insane, then his divorce does not count as such. This is because divorce is dependent upon his being able to decide upon it. Allah says: “And if they decide upon divorce…” (Al-Baqarah 2:227) The one who has lost his mind is unable to decide or intend anything.
But if the word of divorce was uttered with understanding and awareness of the ramifications of divorce, and what it would lead to of separation, then it does count as such.
But if the effect of magic keeps him away from his wife and creates resentment between them, and he cannot find any way to calm down except by uttering the word of divorce – as referred to in the verse in which Allah says: “And from these (angels) people learn that by which they cause separation between man and his wife.” (Al-Baqarah 2:102) – then what appears to be the case is that it does not count as such, because he is not in control of his words and deeds.
Almighty Allah knows best.