I attended a funeral with the Messenger of Allah ﷺ, and the Messenger of Allah ﷺ said, "People, this community will be tested in their graves. When a person is buried and his companions disperse from him, an angel comes to him with a hammer in his hand and sits him up.The angel asks, 'What do you say about this man?' If he is a believer, he says, 'I bear witness that there is no god but Allah and that Muhammad is His servant and Messenger.' The angel says, 'You have spoken truthfully.' Then a door to the Fire is opened for him, and the angel says, 'This would have been your dwelling had you disbelieved in your Lord, but since you believed, this is your dwelling instead,' and a door to Paradise is opened for him. He wants to spring up toward it, but the angel tells him, 'Stay still,' and his grave is expanded for him.But if he is a disbeliever or a hypocrite, the angel asks him, 'What do you say about this man?' He replies, 'I do not know. I heard people saying something, so I said it.' The angel says, 'You did not know, you did not recite, and you were not guided.' Then a door to Paradise is opened for him, and the angel says, 'This would have been your dwelling had you believed in your Lord, but since you disbelieved in Him, Allah has exchanged this for you,' and a door to the Fire is opened for him. Then the angel strikes him a single blow with the hammer that all of Allah's creation hears except for the jinn and mankind."Some of the people said, "Messenger of Allah, no one over whom an angel stands with a hammer in his hand could fail to be terrified out of his senses at that moment."The Messenger of Allah ﷺ replied, "Allah keeps firm those who believe with the firm word" [Ibrahim 14:27].
حدثنا أبو عامر حدثنا عباد يعني ابن راشد عن داود بن أبي هند عن أبي نضرة
شهدت مع رسول الله ﷺ جنازة فقال رسول الله ﷺ أيها الناس إن هذه الأمة تبتلى في قبورها فإذا الإنسان دفن فتفرق عنه أصحابه جاءه ملك في يده مطراق فأقعده قال ما تقول في هذا الرجل فإن كان مؤمنا قال أشهد أن لا إله إلا الله وأن محمدا عبده ورسوله فيقول صدقت ثم يفتح له باب إلى النار فيقول هذا كان منزلك لو كفرت بربك فأما إذ آمنت فهذا منزلك فيفتح له باب إلى الجنة فيريد أن ينهض إليه فيقول له اسكن ويفسح له في قبره وإن كان كافرا أو منافقا يقول له ما تقول في هذا الرجل فيقول لا أدري سمعت الناس يقولون شيئا فيقول لا دريت ولا تليت ولا اهتديت ثم يفتح له باب إلى الجنة فيقول هذا منزلك لو آمنت بربك فأما إذ كفرت به فإن الله عز وجل أبدلك به هذا ويفتح له باب إلى النار ثم يقمعه قمعة بالمطراق يسمعها خلق الله كلهم غير الثقلين فقال بعض القوم يا رسول الله ما أحد يقوم عليه ملك في يده مطراق إلا هبل عند ذلك فقال رسول الله ﷺ {يثبت الله الذين آمنوا بالقول الثابت}
Its isnad is sahih. It is found in Muslim 4/2200, no. 2867, in the Book of Paradise, on the width of the deceased's resting place, and in Ibn Abu Shayba 3/373, and in Ibn Hibban 199, no. 785 Mawarid, and it is found with the same meaning in Bukhari in the Book of Funerals, on the deceased hearing the sound of their sandals, and in Abu Dawud in the Book of Sunnah, on questioning in the grave, and in Tirmidhi in the Book of Funerals, on the punishment of the grave, and in Nasai in the Book of Funerals, on the questioning of the disbeliever.