All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
If someone suffers from a psychological or mental disease, he is not absolved of accountability for his actions in all cases; rather, what should be taken into account is whether he is conscious and he deliberately chooses to do those actions. If the actions that he does – like an oath or a vow – are made without will and choice, and he did so because of being overcome by his disease, then he is not held accountable for that, because he is like a person who does something under duress; but if he does it deliberately and out of choice, then he is held accountable.
Imaam Ash-Shaafi’i said in his book Al-Umm: “If a person loses reason by nature or by an accident which he did not cause to himself by committing a sin, then his divorce is not effective and he is not obliged to pray, and no Hadd (corporal punishment) is applied on him, as his case is like a demented person, an insane person, or a person affected by obsessive whispers or affected by any mental disorder as long as he is affected by it. If he regains his reason and he divorces while in this state, or if he commits a sin that requires a Hadd, then it will be applied on him and he is obliged to carry out the obligations, like an insane person who regains his consciousness: if he divorces while in the state of insanity, his divorce is not effective and if he divorces while he is in the state of consciousness, then his divorce is effective.”
For more benefit, please refer to Fataawa 88725 and 116282.
Allaah Knows best.