Short answer
Yes. Praying in the dark is valid and is not makruh in any of the four schools. The Prophet ﷺ prayed at night in houses that had no lamps. Just make sure you are facing the qibla and the place is clean; many people find a dim room helps them focus.
Darkness has no effect on the validity of salah, and the Hanafi texts do not list it among the disliked things. What matters are the usual conditions: facing the qibla, a clean place and covered awrah. If you cannot tell the qibla in the dark, make your best effort and pray.
The four schools agree on this.
Explanation
Aisha described how she would sleep in front of the Prophet ﷺ while he prayed at night, and added that houses in those days had no lamps. He prayed tahajjud in the dark for years. The four schools agree that there is nothing wrong with praying with the lights off.
Some people have heard that praying in the dark is haram or makruh. There is no basis for this in the hadith or in the fiqh books. For many people a darker room actually helps: there is less to look at, and the heart settles more easily.
- Qibla: work out the direction before you switch the light off; see the qibla finder. If you made an effort and got it wrong, see what if you prayed in the wrong direction.
- Clean spot: make sure the place is clean before it gets dark.
- Fire: the Hanafi texts dislike praying facing an open fire, such as a burning stove, because it resembles fire worship; a lamp or a candle is not disliked.
- Safety: leave enough light that you will not trip, especially for older people.
Night prayer is covered in how to pray tahajjud and can you pray tahajjud right before Fajr.
The evidence
Sahih al-Bukhari 382
Sahih... كنت أنام بين يدي رسول الله ورجلاي في قبلته ...
"I used to sleep in front of the Messenger of Allah with my legs in his qibla."
The same report adds that houses then had no lamps, so he prayed in the dark.
Where the ruling is recorded
- al-Fatawa al-Hindiyya, Kitab al-Salah, chapter on what is disliked in prayer. Praying facing an open fire is disliked, but not facing a lamp or a candle.
- Nur al-Idah with Maraqi al-Falah, Chapter on the conditions of prayer. The conditions of prayer are purity, covering, the qibla, time and intention; light is not among them.
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.