If a person dies and his/her relatives bury him, he will be asked three questions in the grave. What happens after that? Where does his/her soul go?
According to Islamic doctrine, when a person dies, his soul resides in barzakh. The word barzakh means "obstacle" or "barrier". It is a place where the souls will reside until the Day of Resurrection. Allah almighty, may he be glorified and exalted, said regarding barzakh (interpretation of the meaning):
[23.99] Until when death overtakes one of them, he says: Send me back, my Lord, send me back;
[23.100] Haply I may do good in that which I have left. By no means! it is a (mere) word that he speaks; and before them is a barrier until the day they are raised.
There is differences of opinion regarding what exactly happens in the intermediate realm (barzakh). Only Allah almighty has complete knowledge of it. However, we do have many hadiths releted to it. I quoted some of them bellow :
Sumurah bin Jundub (May Allah be pleased with him) said: The Messenger of Allah (ﷺ) very often used to ask his Companions, "Do any one of you has seen a dream?" So dreams would be narrated to him by those whom Allah willed to relate. One day he (ﷺ) said, "Last night I had a vision in which two men (angels) came to me and woke me up and said to me, 'Proceed!' I set out with them and we came across a man lying down, and behold, another man was standing over his head, holding a big rock. Behold, he was throwing the rock at the man's head, smashing it. When he struck him, the stone rolled away and he went after it to get it, and no sooner had he returned to this man, his head was healed and restored to its former condition. The thrower (of the rock) then did the same as he had done before. I said to my two companions, 'Subhan-Allah! Who are these?' They said: 'Proceed, proceed.' So we proceeded and came to a man lying in a prone position and another man standing over his head with an iron hook, and behold, he would put the hook in one side of the man's mouth and tear off that side of his face to the back (of the neck), and similarly tear his nose from front to back, and his eyes from front to back. Then he turned to the other side of the man's face and did just as he has done with the first side. He had hardly completed that (second) side when the first returned to its normal state. I said to my two companions, 'Subhan-Allah! Who are these?' They said, 'Proceed, proceed.' So we proceeded and came across something like a Tannur (a kind of baking oven, a pit usually clay-lined for baking bread)." I (the narrator) think the Prophet (ﷺ) said, "In that oven there was much noise and voices." The Prophet (ﷺ) added, "We looked into it and found naked men and women, and behold, a flame of fire was reaching to them from underneath, and when it reached them they cried loudly. I asked, 'Who are these?' They said to me, 'Proceed, proceed.' And so we proceeded and came across a river." I (the narrator) think he said, "-- red like blood." The Prophet (ﷺ) added, "And behold, in the river there was a man swimming, and on the bank there was a man who had collected many stones. Behold, while the other man was swimming, he went near him. The former opened his mouth and the latter (on the bank) threw a stone into his mouth whereupon he went swimming again. Then again he (the former) returned to him (the latter), and every time the former returned, he opened his mouth, and the latter threw a stone into his mouth, (and so on) the performance was repeated. I asked my two companions, 'Who are these?' They replied, 'Proceed, proceed.' And we proceeded till we came to a man with a repulsive appearance, the most repulsive appearance you ever saw a man having! Beside him there was a fire, and he was kindling it and running around it. I asked my two companions, 'Who is this (man).' They said to me, 'Proceed, proceed!' So we proceeded till we reached a garden of deep green dense vegetation, having all sorts of spring colours. In the midst of the garden there was a very tall man, and I could hardly see his head because of his great height, and around him there were children in such a large number as I have never seen! I said to my two companions, 'Who is this?' They replied, 'Proceed, proceed.' So we proceeded till we came to a majestic, huge garden, greater and better than any garden I have ever seen! My two companions said to me, 'Ascend up' and I ascended up." The Prophet (ﷺ) added, "So we ascended till we reached a city built of gold and silver bricks, and we went to its gate and asked (the gatekeeper) to open the gate, and it was opened; and we entered the city and found in it men with one side of their bodies as handsome as the most handsome person you have ever seen, and the other side as ugly as the ugliest person you have ever seen! My two companions ordered those men to throw themselves into the river. Behold, there was a river flowing across (the city), and its water was like milk in whiteness. Those men went and threw themselves in it and then returned to us after the ugliness (of their bodies) had disappeared, and they came in the best shape." The Prophet (ﷺ) further added, "My two companions said to me: 'This place is the 'Adn Jannah, and that is your place.' I raised up my sight, and behold, there I saw a palace like a white cloud! My two companions said to me, 'That palace is your place,' I said to them, 'May Allah bless you both! Let me enter it.' They replied, 'As for now, you will not enter it, but you shall enter it (one day).' I said to them, 'I have seen many wonders tonight. What does all that mean which I have seen?' They replied, 'We will inform you: As for the first man you came upon, whose head was being smashed with the rock, he is the symbol of the one who studies the Qur'an and then neither recites it nor acts on its orders, and sleeps, neglecting the enjoined prayers. As for the man you came upon, whose sides of mouth, nostrils and eyes were torn off from front to back, he is the symbol of the man who goes out of his house in the morning and tells lies that are spread all over the world. And those naked men and women whom you saw in a construction resembling an oven, they are the adulterers and the adulteresses. And the man who was given a stone to swallow is the eater of Ar-Riba (usury), and the bad-looking man whom you saw near the fire, kindling it and going around it, is Malik, the gatekeeper of Hell, and the tall man you saw in the garden is (Prophet) Abraham, and the children around him are those who died upon Al-Fitrah (the Islamic Faith of Monotheism)."' The narrator added: Some Muslims asked the Prophet (ﷺ) , "O Messenger of Allah! What about the children of Al- Mushrikun (i.e., polytheists, pagans, idolaters, and disbelievers in the Oneness of Allah and in His Messenger Muhammad (ﷺ))?" The Prophet (ﷺ) replied, "And also the children of Al-Mushrikun." The Prophet (ﷺ) added: "My two companions added, 'The men you saw half handsome and half ugly were these people who had mixed an act that was good with another that was bad, but Allah forgave them'."
Another narration of Al-Bukhari is: The Messenger of Allah (ﷺ) said, "One night two men came to me and took me to a blessed land." (The Messenger of Allah (ﷺ) told of the same incident as above) and said, "After a while of walking we came upon a pit like an oven, narrow at the top and wide at the bottom with fire raging in it. When the flames rose up (the people in it) also rose up till they were about to come out; and when the fire subsided they, too, would go down with it. In it were naked men and women." (The remainder of the Hadith is the same as the above Hadith except that at the end of it, the Messenger of Allah said: "We came upon a river of blood in the middle of which there was a man standing, and at the bank of the river there was a man with plenty of stones before him..." In this narration we also find: "They made me climb the tree and they made me enter an abode so beautiful the like of which I have never seen before. There (I saw) old men and youth." In this narration we also find: "'The first house you entered was the abode of the believers in general, and the other house was the abode of the martyrs. I am Jibril (Gabriel), and this is Mika'il. Raise your head.' I looked up and saw something like clouds. They said to me, 'That is your abode.' I said, 'Shall I enter it?' They said, 'You have not completed your term of life yet. When you do, you will certainly enter it."'
Narrated Ibn `Abbas: The Prophet (ﷺ) once passed by two graves and said, "These two persons are being tortured not for a major sin (to avoid). One of them never saved himself from being soiled with his urine, while the other used to go about with calumnies (to make enmity between friends)." The Prophet (ﷺ) then took a green leaf of a date-palm tree, split it into (pieces) and fixed one on each grave. They said, "O Allah's Apostle! Why have you done so?" He replied, "I hope that their punishment might be lessened till these (the pieces of the leaf) become dry." [Sahih al-Bukhari 218]