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
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.”
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.
And Allah knows best.