Sunan an-Nasa'i, Book 21, Hadith 235 (In-Book) ⓘ
It was narrated from Anas that the Prophet said: "When a person is put in his grave and his companions leave him, he hears the sound of their sandals. Two angels come to him, making him sit up, and say to him: 'What did you say about this man (Muhammad)?' As for the believer, he says: 'I bear witness that he says: 'I bear witness that he is the slave of Allah and His Messenger.' It is said to him: 'Look at your place in hell; Allah has replaced it for you with a place better than it.''' The Messenger of Allah said: "Then he sees them both." As for the disbeliever or the hypocrite, it is said to him: 'What did you say about this man?' He says: 'I do not know; I used to say what the people said.' It is said to him: 'You did not understand and you did not follow those who had understanding.' Then he is dealt a blow between his ears and the man utters a scream which everything near him hears, except for the two races.'''
أَخْبَرَنَا أَحْمَدُ بْنُ أَبِي عُبَيْدِ اللَّهِ، قَالَ حَدَّثَنَا يَزِيدُ بْنُ زُرَيْعٍ، عَنْ سَعِيدٍ، عَنْ قَتَادَةَ، عَنْ أَنَسٍ، أَنَّ النَّبِيَّ صلى الله عليه وسلم قَالَ " إِنَّ الْعَبْدَ إِذَا وُضِعَ فِي قَبْرِهِ وَتَوَلَّى عَنْهُ أَصْحَابُهُ إِنَّهُ لَيَسْمَعُ قَرْعَ نِعَالِهِمْ أَتَاهُ مَلَكَانِ فَيُقْعِدَانِهِ فَيَقُولاَنِ لَهُ مَا كُنْتَ تَقُولُ فِي هَذَا الرَّجُلِ مُحَمَّدٍ فَأَمَّا الْمُؤْمِنُ فَيَقُولُ أَشْهَدُ أَنَّهُ عَبْدُ اللَّهِ وَرَسُولُهُ فَيُقَالُ لَهُ انْظُرْ إِلَى مَقْعَدِكَ مِنَ النَّارِ قَدْ أَبْدَلَكَ اللَّهُ بِهِ مَقْعَدًا خَيْرًا مِنْهُ " . قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم " فَيَرَاهُمَا جَمِيعًا وَأَمَّا الْكَافِرُ أَوِ الْمُنَافِقُ فَيُقَالُ لَهُ مَا كُنْتَ تَقُولُ فِي هَذَا الرَّجُلِ فَيَقُولُ لاَ أَدْرِي كُنْتُ أَقُولُ كَمَا يَقُولُ النَّاسُ . فَيُقَالُ لَهُ لاَ دَرَيْتَ وَلاَ تَلَيْتَ . ثُمَّ يُضْرَبُ ضَرْبَةً بَيْنَ أُذُنَيْهِ فَيَصِيحُ صَيْحَةً يَسْمَعُهَا مَنْ يَلِيهِ غَيْرُ الثَّقَلَيْنِ " .
also referenced under: Hadith 2051 (Reference) & Volume 3, Book 21, Hadith 2053 (DarusSalam)