We ask Allah, may He be exalted, to heal you and grant you well-being, and to bless you with happiness and peace of mind.
The basic principle is that if a man divorces his wife (talaaq) when she is in a state of purity during which he has not had intercourse with her, or when she is pregnant, the divorce is valid and counts as such. But Islam overlooks and does not count as valid divorce issued at the time of coercion, as Ibn Maajah (2046) narrated from Aa'ishah that the Messenger of Allah (blessings and peace of Allah be upon him) said: There is no divorce and no manumission at the time of coercion. Classed as hasan by al-Albaani.
Al-Bukhaari included a chapter in his Saheeh entitled: Chapter on divorce at the time of coercion and by one who is forced, drunk or insane; errors and forgetfulness in the case of divorce, shirk, and so on, because the Prophet (blessings and peace of Allah be upon him) said: Actions are but by intention and each man will have but that which he intended; ash-Sha bi recited (interpretation of the meaning): Punish us not if we forget or fall into error [al-Baqarah 2:286]; and what is not permitted of confession from one who suffers whispers from the Shaytaan; the Prophet (blessings and peace of Allah be upon him) said to the one who confessed against himself: Are you insane?; Utbah ibn Aamir said: Divorce (talaaq) issued by one who is affected by waswaas (whispers from the Shaytaan) does not count as such. End quote.
Coercion includes being compelled, not being able to think properly, and losing willpower. This happens to the one who is affected by waswaas sometimes, and to the one who has been bewitched, and to some of those who suffer from depression, in such a way that one of them may divorce his wife by compulsion, without choosing or wanting to do so; rather he finds himself pushed or compelled to divorce his wife, and he cannot relax until he speaks of it. In such a case the divorce does not count as such.
Ibn al-Qayyim (may Allah have mercy on him) said: Our shaykh, Ibn Taymiyah, said: Coercion means one is no longer aware of what he is saying and is unable to form an intention. That includes divorce issued by one who is mentally deficient, insane or drunk, one who is forced to do that, and one who is so angry that he does not know what he is saying, because in all of these cases the door has been closed to awareness and intention. Divorce only counts as such if it is issued by one who intends, knowingly, to do that.
End quote from Haashiyat as-Sunan, 6/187
Based on that, if you spoke the word of divorce, understanding it and aware of its impact, and intended to separate from your wife, then this is a divorce that counts as such.
But if you uttered it without realising, under the pressure of your illness and distress, then it does not count as such.
Even if we assume that divorce took place, you have the option of taking your wife back if her iddah has not yet ended, or you can make a new marriage contract with her, fulfilling the necessary conditions, if she agrees to that and if this was the first or second talaaq.
We should point out that if a person divorces his wife three times or more (at one time) by saying You are thrice divorced or You are divorced, you are divorced, you are divorced, this is to be counted as a single divorce according to the more correct opinion. The same applies if he issues a divorce, then issues another divorce before taking back his wife; this is to be counted as a single divorce, according to the more correct opinion, whether it was on a single occasion or on several occasions, because divorce cannot take place except after doing the marriage contract or after taking back the wife.
For more information please see question no. 96194 and 126549
And Allah knows best.
Reproduced from Islam QA