Short answer
No. You are not accountable for what you do in a dream, even if you dream of committing a major sin or saying words of disbelief. The Prophet ﷺ said the pen is lifted from the sleeper until he wakes. The only rulings that follow a dream are physical ones, such as ghusl after a wet dream.
A sleeper is not legally responsible, so no sin is written for what happens in a dream. Ghusl is fard if you wake to find discharge from a wet dream. Dreams do not affect faith or marriage.
The four schools agree on this.
Explanation
The Prophet ﷺ said that the pen is lifted from three: the sleeper until he wakes, the child until he grows up, and the insane until he regains his mind. 'The pen is lifted' means nothing is written against them. Allah does not burden a soul beyond what it can bear, and nobody controls their dreams.
This covers all kinds of dreams that leave people anxious:
- dreaming of zina, drinking, or eating pork;
- dreaming that you insulted Allah, left Islam or prayed to an idol;
- dreaming that you divorced your spouse or swore an oath;
- dreaming that you missed salah or broke your fast.
None of these is a sin, none affects your faith, and a talaq or oath in a dream does not count. Dreaming that you ate or drank does not break a fast either.
What does follow from a dream is physical. If you wake to find wetness from a sexual dream, ghusl is fard (see ghusl after a wet dream), and in Ramadan the fast is still valid (see does a wet dream break your fast).
If sinful dreams keep coming back, they may reflect what you look at or think about during the day, or they may be Shaytan trying to upset you. Guard your eyes, sleep with wudu and the bedtime adhkar, and follow the steps in after a bad dream. If the worry turns into constant doubts, that is waswasa; talk to a scholar you trust. The four schools agree on this ruling.
The evidence
Quran, Surah Al-Baqara 2:286
لَا يُكَلِّفُ ٱللَّهُ نَفْسًا إِلَّا وُسْعَهَا ۚ لَهَا مَا كَسَبَتْ وَعَلَيْهَا مَا ٱكْتَسَبَتْ ۗ رَبَّنَا لَا تُؤَاخِذْنَآ إِن نَّسِينَآ أَوْ أَخْطَأْنَا ۚ رَبَّنَا وَلَا تَحْمِلْ عَلَيْنَآ إِصْرًۭا كَمَا حَمَلْتَهُۥ عَلَى ٱلَّذِينَ مِن قَبْلِنَا ۚ رَبَّنَا وَلَا تُحَمِّلْنَا مَا لَا طَاقَةَ لَنَا بِهِۦ ۖ وَٱعْفُ عَنَّا وَٱغْفِرْ لَنَا وَٱرْحَمْنَآ ۚ أَنتَ مَوْلَىٰنَا فَٱنصُرْنَا عَلَى ٱلْقَوْمِ ٱلْكَٰفِرِينَ ﴿٢٨٦﴾
Allah does not charge a soul except [with that within] its capacity. It will have [the consequence of] what [good] it has gained, and it will bear [the consequence of] what [evil] it has earned. "Our Lord, do not impose blame upon us if we have forgotten or erred. Our Lord, and lay not upon us a burden like that which You laid upon those before us. Our Lord, and burden us not with that which we have no ability to bear. And pardon us; and forgive us; and have mercy upon us. You are our protector, so give us victory over the disbelieving people."
No one is held to what they cannot control.
Sunan Abi Dawud 4398
Graded sahih... رفع القلم عن ثلاثة عن النائم حتى يستيقظ ...
"The pen is lifted from three: from the sleeper until he wakes."
Nothing done in sleep is written as a sin.
Where the ruling is recorded
- Radd al-Muhtar (Ibn Abidin), Kitab al-Talaq. Words of divorce spoken by a sleeper have no effect.
- al-Hidaya, Kitab al-Taharah, section on what requires ghusl. Ghusl after a wet dream depends on finding discharge.
Checked by our team. For a more accurate answer to your own situation, consult a scholar. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.