كتاب الفضائل
43  
The Book of Virtues
(8)
Chapter: When Allah Wants To Show Mercy To A Nation, He takes Their Prophet Before Them
(8)
باب إِذَا أَرَادَ اللَّهُ تَعَالَى رَحْمَةَ أُمَّةٍ قَبَضَ نَبِيَّهَا قَبْلَهَا ‏‏
Sahih Muslim 2288

Abu Musa reported Allah's Messenger (ﷺ) as saying:

When Allah, the Exalted and Glorious, intends to show mercy to an Umma from amongst His servants He calls back His Apostle to his eternal home and makes him a harbinger and recompense in the world to come; and when He intends to cause destruction to an Umma, He punishes it while its Apostle is alive and He destroys it as he (the Apostle) witnesses it and he cools his eyes by destruction as they had belied him and disobeyed his command.
قَالَ مُسْلِمٌ وَحُدِّثْتُ عَنْ أَبِي أُسَامَةَ، وَمِمَّنْ، رَوَى ذَلِكَ، عَنْهُ إِبْرَاهِيمُ بْنُ سَعِيدٍ الْجَوْهَرِيُّ حَدَّثَنَا أَبُو أُسَامَةَ، حَدَّثَنِي بُرَيْدُ بْنُ عَبْدِ اللَّهِ، عَنْ أَبِي بُرْدَةَ، عَنْ أَبِي مُوسَى، عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ ‏ "‏ إِنَّ اللَّهَ عَزَّ وَجَلَّ إِذَا أَرَادَ رَحْمَةَ أُمَّةٍ مِنْ عِبَادِهِ قَبَضَ نَبِيَّهَا قَبْلَهَا فَجَعَلَهُ لَهَا فَرَطًا وَسَلَفًا بَيْنَ يَدَيْهَا وَإِذَا أَرَادَ هَلَكَةَ أُمَّةٍ عَذَّبَهَا وَنَبِيُّهَا حَىٌّ فَأَهْلَكَهَا وَهُوَ يَنْظُرُ فَأَقَرَّ عَيْنَهُ بِهَلَكَتِهَا حِينَ كَذَّبُوهُ وَعَصَوْا أَمْرَهُ ‏"‏ ‏.‏
Reference : Sahih Muslim 2288
In-book reference : Book 43, Hadith 28
USC-MSA web (English) reference : Book 30, Hadith 5679
  (deprecated numbering scheme)