Short answer
Lucid dreaming itself is not haram, and what happens in a dream is not counted against you, because the pen is lifted from the sleeper. But deliberately training yourself to act out haram desires in dreams, or using dreams to contact spirits or see the unseen, is not allowed. Dreams carry no rulings.
A sleeper is not accountable for what he does in a dream. Techniques to become aware in dreams are mubah in themselves, but using them to pursue sinful desires, or for occult aims, is not permitted, since resolving on sin while awake is blameworthy.
The four schools agree on this.
Explanation
Lucid dreaming means becoming aware that you are dreaming while the dream continues, and sometimes steering it. Scholars of the past did not write about it under this name, so the answer comes from established principles about sleep and dreams.
First, the sleeper is not held responsible. The Prophet ﷺ said the pen is lifted from three, including the sleeper until he wakes. So if something sinful happens in any dream, lucid or not, you carry no sin for it, and it does not break your fast or your wudu by itself. A wet dream only requires ghusl.
Second, what you choose while awake does count. Allah forgives passing thoughts, but a person who sets out, with planning and practice, to live out zina, violence or other haram fantasies in his dreams is feeding desires Islam asks him to restrain. Scholars warn that this weakens the heart even if the dream itself is not written as a sin. The same applies to using lucid dreams or 'astral projection' to meet jinn or spirits, or to claim knowledge of the unseen: these go against tawhid.
Practical points:
- Keeping a dream journal, or noticing in a dream that you are dreaming, is harmless.
- Do not let dream practices ruin your sleep, health or Fajr.
- Do not make up dreams or embellish them. The Prophet ﷺ warned that whoever claims a dream he did not see will be made to tie two grains of barley together.
- Dreams are not a source of rulings. Even a good dream is only glad tidings.
More on the three kinds of dreams in Dreams in Islam.
The evidence
Quran, Surah Az-Zumar 39:42
ٱللَّهُ يَتَوَفَّى ٱلْأَنفُسَ حِينَ مَوْتِهَا وَٱلَّتِى لَمْ تَمُتْ فِى مَنَامِهَا ۖ فَيُمْسِكُ ٱلَّتِى قَضَىٰ عَلَيْهَا ٱلْمَوْتَ وَيُرْسِلُ ٱلْأُخْرَىٰٓ إِلَىٰٓ أَجَلٍۢ مُّسَمًّى ۚ إِنَّ فِى ذَٰلِكَ لَءَايَٰتٍۢ لِّقَوْمٍۢ يَتَفَكَّرُونَ ﴿٤٢﴾
Allah takes the souls at the time of their death, and those that do not die [He takes] during their sleep. Then He keeps those for which He has decreed death and releases the others for a specified term. Indeed in that are signs for a people who give thought.
Sleep is a state in which Allah takes the soul, unlike waking choice.
Sunan Abi Dawud 4403
Graded sahih... رفع القلم عن ثلاثة عن النائم حتى يستيقظ ...
"The pen is lifted from three: from the sleeper until he wakes up."
A sleeper is not accountable for what happens in his dreams.
Sahih al-Bukhari 7042
Sahih... من تحلم بحلم لم يره كلف أن يعقد بين شعيرتين ...
"Whoever claims to have seen a dream he did not see will be made to tie two barley grains together."
Lying about dreams is a serious sin.
Sahih al-Bukhari 5269
Sahih... إن الله تجاوز عن أمتي ما حدثت به أنفسها ما لم تعمل أو تتكلم ...
"Allah has pardoned my ummah for what their souls whisper, as long as they do not act on it or speak of it."
Passing thoughts are forgiven, but deliberate pursuit of sin is a different matter.
Where the ruling is recorded
- Kashf al-Asrar (Abd al-Aziz al-Bukhari), Chapter on impediments to legal capacity, the section on sleep. Sleep suspends accountability for speech and acts while it lasts.
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.