Abu Hurairah reported,

The Prophet ﷺ said, "When a person is dying, the angels come to him. If the man has been righteous, they say, 'Come out, pure soul that was in a pure body. Come out praiseworthy, and receive the glad tidings of rest, fragrance, and a Lord who is not angry.' This continues to be said to it until it comes out. Then it is taken up to heaven, and it is opened for it.It is asked, 'Who is this?'They reply, 'So-and-so.'It is said, 'Welcome to the pure soul that was in a pure body. Enter praiseworthy, and receive the glad tidings of rest, fragrance, and a Lord who is not angry.' This continues to be said to it until it reaches the heaven in which Allah عز وجل is.But if the man has been wicked, the angel says, 'Come out, foul soul that was in a foul body. Come out blameworthy, and receive the tidings of scalding water, festering pus, and other torments of the same kind in pairs.' This continues to be said to it until it comes out. Then it is taken up to heaven, but it is not opened for it.It is asked, 'Who is this?'It is said, 'So-and-so.'It is said, 'No welcome to the foul soul that was in a foul body. Go back blameworthy, for the gates of heaven shall not be opened to you.' So it is sent back down from the sky, and then it goes to the grave."

Ibn Majah 4262

Sahih

حدثنا أبو بكر بن أبي شيبة حدثنا شبابة عن ابن أبي ذئب عن محمد بن عمرو بن عطاء عن سعيد بن يسار

عن أبي هريرة

عن النبي ﷺ قال الميت تحضره الملائكة فإذا كان الرجل صالحا قالوا اخرجي أيتها النفس الطيبة كانت في الجسد الطيب اخرجي حميدة وأبشري بروح وريحان ورب غير غضبان فلا يزال يقال لها ذلك حتى تخرج ثم يعرج بها إلى السماء فيفتح لها فيقال من هذا فيقولون فلان فيقال مرحبا بالنفس الطيبة كانت في الجسد الطيب ادخلي حميدة وأبشري بروح وريحان ورب غير غضبان فلا يزال يقال لها ذلك حتى ينتهى بها إلى السماء التي فيها الله عز وجل وإذا كان الرجل السوء قال اخرجي أيتها النفس الخبيثة كانت في الجسد الخبيث اخرجي ذميمة وأبشري بحميم وغساق وآخر من شكله أزواج فلا يزال يقال لها ذلك حتى تخرج ثم يعرج بها إلى السماء فلا يفتح لها فيقال من هذا فيقال فلان فيقال لا مرحبا بالنفس الخبيثة كانت في الجسد الخبيث ارجعي ذميمة فإنها لا تفتح لك أبواب السماء فيرسل بها من السماء ثم تصير إلى القبر

ابن ماجه 4262صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Asceticism
Chapter
Death and preparing for it
Numbering
Darussalam 4262
Ibn Majah 4262