Praise be to Allah.
Imam Ahmad (17803) narrated that al-Bara’ ibn ‘Aazib (may Allah be pleased with him) said:
“Verily, when the believing slave is about to depart this world and enter the Hereafter, there come down to him angels from heaven with white faces, as if their faces are the sun. They bring with them one of the shrouds of Paradise and some of the perfume of Paradise. They sit with him as far as the eye can see. Then the Angel of Death (peace be upon him) comes to him and sits by his head and says, ‘O pure soul, come out to the forgiveness and pleasure of Allah.’ Then his soul comes flowing out like a drop of water flowing from a cup. Then he takes the soul, and no sooner does he seize it but they take it and place it in that shroud and perfume. Then out of it comes the most excellent fragrance of musk to be found on the face of the earth. Then they ascend with it and they do not pass by any group of angels but the angels ask, ‘Who is this pure soul?’ and they reply, ‘It is So and so the son of So and so’ – using the best names by which he was known on earth. Then they bring it to the lowest heaven, and ask for it to be opened, and it is opened for him. Those who are of high rank in each heaven accompany it until they approach the next heaven, and so it goes until it reaches the seventh heaven. Then Allah, may He be glorified and exalted, says: ‘Record the book of My slave in ‘Illiyoon (the highest heaven) and take him back to the earth, for I created them from it, and I shall return them to it, then I shall take them out from it again.’ Then his soul is returned to his body and two angels come and make him sit up”
Then the hadith mentions the questioning in the grave, then it mentions how the soul of the disbeliever is taken, then it says:
“Then they ascend with it and they do not pass by any group of angels but the angels ask, ‘Who is this evil soul?’ and they reply, ‘It is So and so the son of So and so’ – using the worst names by which he was known on earth. Then they bring it to the lowest heaven, and ask for it to be opened, and it is not opened for him.” Then the Messenger of Allah (peace and blessings of Allah be upon him) recited (interpretation of the meaning): “… For them the gates of heaven will not be opened, and they will not enter Paradise until the camel goes through the eye of the needle” [al-A’raaf 7:40]. Then he said, “Then Allah, may He be glorified and exalted, says: ‘Record the book of My slave in Sijjeen (the lowest Hell) in the lowest earth. Then his soul is cast down.” Then he recited (interpretation of the meaning): “… and whoever assigns partners to Allah, it is as if he had fallen from the sky, and the birds had snatched him, or the wind had thrown him to a far off place.” [al-Hajj 22:31]. He said, “Then his soul is returned to his body and two angels come and make him sit up” Then it mentions the questioning in the grave.
Classed as saheeh by al-Albaani in Saheeh al-Jaami‘ (1676)
Please see also the answer to question no. 4395
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
This hadith indicates that the soul will remain after it departs the body, contrary to the misguided teachings of the mutakallimeen (Muslim philosophers); and that it will ascend and descend, contrary to the misguided teachings of the philosophers; and that it will be returned to the body; and that the deceased will be questioned, then he will be subjected to bliss or punishment.
End quote from Majmoo‘ al-Fataawa (4/292)
Ibn Maajah (4262) narrated from Abu Hurayrah that the Prophet (blessings and peace of Allah be upon him) said:
“Angels come to the dying person and if the man was righteous, they say: ‘Come out, O good soul that was in a good body, come out praiseworthy and receive the glad tidings of mercy and fragrance and a Lord Who is not angry.’ And this is repeated until it comes out, then it is taken up to heaven, and it is opened for it, and it is asked, ‘Who is this?’ They say: ‘[It is] So and so.’ It is said: ‘Welcome to the good soul that was in a good body. Enter praiseworthy and receive the glad tidings of mercy and fragrance and a Lord Who is not angry.’ And this is repeated until it is brought to the heaven above which is Allah, may He be glorified and exalted. But if the man was evil, they say: ‘Come out O evil soul that was in an evil body. Come out blameworthy and receive the tidings of boiling water and dirty wound discharges, and other torments of similar kind, all together [cf. Saad 38:58]. And this is repeated until it comes out, then it is taken up to heaven and it is not opened for it. And it is said: ‘No welcome to the evil soul that was in an evil body. Go back blameworthy, for the gates of heaven will not be opened to you.’ So it is sent back down from heaven, then it goes to the grave.”
Classed as saheeh by al-Albaani in Saheeh Ibn Maajah.
These two hadiths describe what happens to the soul after death and before burial: if the person was a believer, then the angels give him glad tidings, before taking his soul, of the forgiveness and good pleasure of Allah, then they perfume it, then they take it up, in a blessed state, to its Lord, may He be glorified. Then Allah, may He be glorified and exalted, says: “‘Record the book of My slave in ‘Illiyoon (the highest heaven) and take him back to the earth.” So the soul is returned to the body in which it was, then the individual is questioned in the grave; Allah makes him steadfast at the time of questioning, and makes his grave spacious for him, as far as his eyes can see.
But if it is the soul of a disbeliever, then the angels give him the tidings of hell and divine wrath, then they take his soul up, cursed, humiliated and afraid, and the gates of heaven are not opened for it, then it is thrown back down to earth, then it is returned to its body, then the individual is tormented in his grave and it is compressed on him, and there comes to him the heat and smoke of Hell.
With regard to the period between the departure of the soul and burial and questioning in the grave, for the believer it is the first stage of eternal happiness, as he is given the glad tidings of Paradise and eternal bliss, and his book is recorded in ‘Illiyoon (the highest heaven); then his soul will rejoice and be happy, and will never feel misery again.
But for the disbeliever, it is the first stage of eternal torment, as Allah is angry with him and does not give permission for the gates of heaven or the gates of mercy to be opened to him, and his book is recorded in Sijjeen (the lowest Hell); then his soul will be wretched and he will never feel happy again.
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
All the saheeh, mutwawaatir hadiths indicate that the soul will return to the body; the idea that the questioning will involve the body without the soul was suggested by some scholars, but the majority disagreed with that. Similarly, the idea that the questioning will involve the soul without the body was suggested by Ibn Maysarah and Ibn Hazm, but if that were the case, the grave would have nothing to do with the soul.
End quote from Majmoo‘ al-Fataawa (5/446)
See also: Fataawa Noor ‘ala ad-Darb by Shaykh al-‘Uthaymeen (may Allah have mercy on him) (4/310-311)
These matters are matters of the unseen which the Muslim must accept, and not question how they are, for no one knows how the life of al-barzakh [the period between death and the Resurrection] is except Allah.
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) was asked:
The death of a person signals the departure of the soul from the body; when he is buried in his grave, is the soul returned to his body, or where does it go? If the soul is returned to the body in the grave, how does that happen?
It is proven from the Messenger of Allah (blessings and peace of Allah be upon him) that when a person dies, his soul is returned to him in his grave, and he is questioned about his Lord, his religion and his Prophet. Allah will keep firm those who believe, with the word that stands firm in this world and in the Hereafter (cf. Ibraaheem 14:27), so the believer will say: My Lord is Allah, my religion is Islam and my Prophet is Muhammad (blessings and peace of Allah be upon him). As for the disbeliever or the hypocrite, when he is questioned he will say: Oh, oh, I do not know; I heard the people saying something, so I said it too.
This return of the soul to the body in the grave will not be like when a person’s soul is in his body in this world, because that is the life of al-barzakh and we do not know how it is, because we have not been told about the nature of that life. With regard to all matters of the hereafter of which we have not been told, what we are required to do with regard to such matters is to accept them and not enquire any further, because Allah, may He be exalted, says (interpretation of the meaning):
“And follow not (O man i.e., say not, or do not or witness not, etc.) that of which you have no knowledge (e.g. ones saying: ‘I have seen,’ while in fact he has not seen, or ‘I have heard,’ while he has not heard). Verily! The hearing, and the sight, and the heart, of each of those you will be questioned (by Allah)”
End quote from Fataawa Noor ‘ala ad-Darb by al-‘Uthaymeen (4/2)
And Allah knows best.