During sleep, our souls depart from our bodies in an obscure manner. The soul of every sleeping person is held by Allaah, and He then releases it when it is time to wake up. This is expressed by texts from both the Qur'aan and the Sunnah.
Texts From The Qur'aan
Allaah سبحانه و تعالى says,
"It is He, Who takes your souls by night (when you are asleep), and has knowledge of all that you have done by day, then he raises (wakes) you up again that a term appointed (your life period) be fulfilled, then in the end unto Him will be your return. Then He will inform you what you used to do." (Sooratul-An'aam, 6:60)
And Allaah سبحانه و تعالى says,
"Allaah 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." (Sooratuz-Zumar, 39:42)
Commenting on this aayah, Imaam al-Qurtubi رحمه الله said: "Allaah سبحانه و تعالى takes away the soul at the end of a person's term, as well as those in sleep... Thus, He holds the souls for which death has arrived, and releases the other souls until the time of their death... Ibn 'Abbaas رضي الله عنهما and others said, 'The souls of the living and of the dead meet during sleep and get acquainted as Allaah سبحانه و تعالى wills. When they later wish to return to the bodies, Allaah سبحانه و تعالى keeps with Him the souls of the dead, and sends the souls of the living back to their bodies.' Al-Qushayri Abu Nasr رحمه الله said, 'Allaah سبحانه و تعالى takes the souls in the states of sleep and death. He then restricts the actions of those in the state of sleep, and keeps those in the state of death until Resurrection Day.' Allaah سبحانه و تعالى takes the souls during sleep by (temporarily) removing their feelings and replacing perception with unawareness. And He takes them at death by completely removing perception." [1]
Shaykh Muhammad Ibn Saalih al-'Uthaymeen رحمه الله said, "When a person goes to sleep, Allaah سبحانه و تعالى takes away his soul in a form of minor death during which the soul goes to wherever Allaah سبحانه و تعالى wills." [2]
Texts From The Sunnah
Among the sleep-time adhkaar taught by the Prophet صلى الله عليه وسلم is:
"With Your Name, my Lord, I lay down my side, and by You (i.e. Your permission and help) I raise it. If You hold my soul (by death), show it mercy, and if You release it (i.e. keep it alive) then protect it as You protect Yoru righteous servants." [3]
Similarly, the Prophet صلى الله عليه وسلم recommended saying before going to sleep: "O Allaah, You created my soul, and You take it away. You decide its (i.e. my) death and living. If You keep it alive, safeguard it, and if You make it die, forgive it." [4]
And the Prophet صلى الله عليه وسلم used to say when he woke up: "Praise be to Allaah who resurrected us after He made us die. And to Him will be the (people's) emergence (from the graves)." [5]
And the Prophet recommended saying upon waking up: "Praise be to Allaah who granted me well-being in my body, returned my soul to me, and permitted me to extoll Him." [6]
Referring to sleep, Abu Qataadah رضي الله عنه reported that the Prophet صلى الله عليه وسلم said: "Indeed, Allaah took away our souls (during sleep) when He willed, and returned them to us when He willed." [7]
We learn from the above texts that sleep is a minor death in which the soul leaves the body by Allaah's will and control سبحانه و تعالى. This was further confirmed by the Prophet صلى الله عليه وسلم when he negated both forms of death for the people of Jannah. Jaabir رضي الله عنه and 'Abdullaah Ibn Awfaa رضي الله عنه reported that the Prophet صلى الله عليه وسلم said: "Sleep is the brother of death. And the people of Jannah do not sleep." [8]
During the 'minor death', a soul gets to meet other souls of both living and dead people. Khuzaymah رضي الله عنه reported that he had a dream that he was prostrating upon the Prophet's forehead صلى الله عليه وسلم. When he told this to the Prophet صلى الله عليه وسلم, the Prophet صلى الله عليه وسلم leaned back and said: "Indeed, a soul surely meets another soul (during sleep). Confirm your dream: sit and prostrate and do as you did in the dream." [9]
Seeing specific individuals during sleep normally means that Allaah سبحانه و تعالى has created their resemblance in the dreamer's mind. However, there are times when the dreamer's soul actually meets other souls of living or dead people. Its interaction with these souls may remain imprinted in the dreamer's mind after awakening. There is no indication that the other souls would remember the encounter, especially because the Prophet صلى الله عليه وسلم did not indicate remembering encountering Khuzaymah's soul رضي الله عنه. The encounter of souls is an obscure matter of ghayb, and cannot be subjected to out worldly standards. [10]
We should note that the above texts indicate that a person's soul travels very fast so as to meet other souls, angels, etc. Even if he sleeps for just a brief moment, his soul is taken and then returned to his body during that moment. Since the soul and its actions are affairs of ghaybwhich cannot be subjected to the laws of this world, the only correct approach is to accept and believe in all of the information about them that is based on authentic texts.
Allaah سبحانه و تعالى sends the soul during sleep on a mysterious journey that involves amazing visions and encounters. As for the souls whose term in this life has not yet ended, Allaah سبحانه و تعالى sends them back to their bodies. These released souls may then remember and relate some of what they experience during their journey (i.e. dreams)." [11]
Notes:
[1] Imaam al-Qurtubi رحمه الله, al-Jaami' li-Ahkaam al-Qur'aan
[2] Shaykh Muhammad Ibn Saalih al-'Uthaymeen رحمه الله, Sharh Riyaadh as-Saaliheen
[3] Recorded by al-Bukhaari رحمه الله, Muslim رحمه الله and others from Abu Hurayrah رضي الله عنه.
[4] Recorded by Muslim رحمه الله from Ibn 'Umar رضي الله عنهما.
[5] Recorded by al-Bukhaari رحمه الله, Imaam Muslim رحمه الله and others from Hudhayfah and al-Baraa'.
[6] Recorded by at-Tirmidhi رحمه الله, Ibn us-Sunni رحمه الله and others from Abu Hurayrah رضي الله عنه. Verified to be authentic by Shaykh al-Albaani رحمه الله.
[7] This happened when the Prophet صلى الله عليه وسلم and his Companions رضي الله عنهم stopped to rest during their return from the battle of Khaybar and were so exhausted that they slept through the time of the Fajr prayer. This was recorded by al-Bukhari رحمه الله and Muslim رحمه الله, from Abu Hurayrah رضي الله عنه, Abu Qataadah رضي الله عنه and others.
[8] Recorded by Ibn 'Adiyy رحمه الله, Abu Nu'aym رحمه الله and others. Verified to be authentic by Shaykh al-Albaani رحمه الله.
[9] Recorded by Ahmad رحمه الله, Ibn Abi Shaybah رحمه الله and others. Verified to be authentic by Shaykh al-Albaani رحمه الله.
[10] See also: The Human Soul - http://www.muftisays.com/forums/12-virtues/9613-the-human-soul.html
[11] Shaykh Muhammad al-Jibaly, The Dreamers Handbook, pp. 4-9.