Usamah bin Zayd (may Allah be pleased with him) said: The granddaughter of the Prophet (peace and blessings be upon him) was brought to him while her breath was rattling, as if it were in a water-skin. The Messenger of Allah (peace and blessings be upon him) said: "To Allah belongs what He has taken and what He has given, and everyone is moving towards his appointed time." Usamah (may Allah be pleased with him) said: And he (peace and blessings be upon him) wept. Sa'd bin Ubadah (may Allah be pleased with him) said to him (peace and blessings be upon him): O Messenger of Allah! Do you weep, when it was you (peace and blessings be upon him) who forbade weeping? He (peace and blessings be upon him) said: "This is only mercy, which Allah Almighty has placed in the hearts of His servants, and Allah shows mercy only to those of His servants who are merciful."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الجنائز / 7149