Sunan an-Nasa'i, Volume 3, Book 21, Hadith 1844 (DarusSalam)

It was narrated that Ibn 'Abbas said: "When a young daughter of the Messenger of Allah was dying, the Messenger of Allah picked her up and held her to his chest, then he put his hand on her, and she died in front of the Messenger of Allah. Umm Ayman wept and the Messenger of Allah said 'Oh Umm Ayman, do you weep while the Messenger of Allah is with you?' She said: 'Why shouldn't I weep when the Messenger of Allah is weeping." So the Messenger of Allah said "Verily, I am not weeping. Rather it is compassion.' Then the Messenger of Allah said: 'The believer is fine whatever the situation; even when his soul is being pulled from his body and he praises Allah, the Mighty and Sublime"'

أَخْبَرَنَا هَنَّادُ بْنُ السَّرِيِّ، قَالَ حَدَّثَنَا أَبُو الأَحْوَصِ، عَنْ عَطَاءِ بْنِ السَّائِبِ، عَنْ عِكْرِمَةَ، عَنِ ابْنِ عَبَّاسِ، قَالَ لَمَّا حُضِرَتْ بِنْتٌ لِرَسُولِ اللَّهِ صلى الله عليه وسلم صَغِيرَةٌ فَأَخَذَهَا رَسُولُ اللَّهِ صلى الله عليه وسلم فَضَمَّهَا إِلَى صَدْرِهِ ثُمَّ وَضَعَ يَدَهُ عَلَيْهَا فَقَضَتْ وَهِيَ بَيْنَ يَدَىْ رَسُولِ اللَّهِ صلى الله عليه وسلم فَبَكَتْ أُمُّ أَيْمَنَ فَقَالَ لَهَا رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ يَا أُمَّ أَيْمَنَ أَتَبْكِينَ وَرَسُولُ اللَّهِ صلى الله عليه وسلم عِنْدَكِ ‏"‏ ‏.‏ فَقَالَتْ مَا لِي لاَ أَبْكِي وَرَسُولُ اللَّهِ صلى الله عليه وسلم يَبْكِي فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ إِنِّي لَسْتُ أَبْكِي وَلَكِنَّهَا رَحْمَةٌ ‏"‏ ‏.‏ ثُمَّ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ الْمُؤْمِنُ بِخَيْرٍ عَلَى كُلِّ حَالٍ تُنْزَعُ نَفْسُهُ مِنْ بَيْنِ جَنْبَيْهِ وَهُوَ يَحْمَدُ اللَّهَ عَزَّ وَجَلَّ ‏"‏ ‏.‏

sunnah.com