The Connection of the Soul to the Body
A short essay on the soul's connection to the body, in this life and in the Hereafter.
When a person is asleep, his soul is in his body and he is alive, although his being alive is not the same as that of a person who is awake, for sleep is comparable to death.
The soul (ar-rooh) is connected to the body in five different ways, to which different rules apply.  Its connection to the body as a fetus in his mother’s womb.  Its connection to the body after a person is born.  Its connection to the body when a person is asleep, when the soul is connected in one way and separated from it in another way.  Its connection to the body in al-Barzakh (the period between a person’s death and the Day of Resurrection), when it has departed from the body and separated from it, but is not separated completely in such a way that there is no connection at all. We have mentioned at the beginning of this reply that there are aḥādīth and reports which indicate that the soul is returned to the body when somebody sends the greeting of salām to a deceased person. This returning is of a special nature which does not mean that the life is restored to the body before the Day of Resurrection.  Its connection to the body on the Day when bodies will be resurrected. This is the most perfect type of connection to the body, and has no comparison to the previous types, because after that the body will never die, sleep or have anything wrong with it. When a person is asleep, his soul is in his body and he is alive, although his being alive is not the same as that of a person who is awake, for sleep is comparable to death. Similarly, when a dead person’s soul is returned to his body (when the greeting is sent upon him), he is in a state between one who is alive and one who is dead, whose soul is not restored to his body. This is like the case of a sleeping person who is in a state between life and death. We hope that this will dispel a lot of your confusion.
 Taken from Kitāb al-Rūḥ (p. 44)