Islamic teaching describes an intermediate stage between death and the Resurrection called the barzakh, during which the soul experiences something of a preview of its final outcome. For the righteous, the grave is described as being widened and filled with ease, likened to a garden from Paradise, a place of rest while they await the Final Day. For those who lived heedlessly or unjustly, the grave can instead press in with distress — a foretaste of accountability, tied in the hadith literature to specific failings like harsh gossip or carelessness about ritual purity. This isn't meant to terrify anyone into despair; it's meant to gently sharpen our sense that death is not the end of consequence, and to make us kinder and more sincere while we still can be. Allah's mercy remains vast even here — the Quran describes Pharaoh's people being 'exposed to the Fire morning and evening' as a specific example of grave torment for the deeply unjust (40:46), which by contrast highlights that ordinary believers, even flawed ones, are held in Allah's mercy. Many Muslims recite a dua asking Allah for protection from the trial and punishment of the grave, for themselves and their loved ones.
Q&A · Death & Afterlife
What does Islam teach about the 'punishment' and comfort of the grave?
References
Informational, not a personal fatwa. Consult a qualified scholar for rulings on your situation.