Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
tabarani:13027Bakr > ʿAbdullāh > Muʿāwiyah > ʿAlī b. Abū Ṭalḥah

[Machine] In His saying {Those who, when afflicted with a calamity, say, "Indeed we belong to Allah, and indeed to Him we will return." It is those who will be awarded blessings and mercy from their Lord and it is those who are [rightly] guided.} Allah informs us that when a believer submits to the command of Allah and returns to Him, and then turns back to Him in times of affliction, three qualities of goodness are written for Him: prayer, mercy, and the realization of the path of guidance. The Messenger of Allah ﷺ said, "Whoever turns back to Allah in times of calamity, Allah will mend his calamity, better his outcome, and make for him a righteous successor that pleases Him."  

الطبراني:١٣٠٢٧حَدَّثَنَا بَكْرٌ ثنا عَبْدُ اللهِ حَدَّثَنِي مُعَاوِيَةُ عَنْ عَلِيِّ بْنِ أَبِي طَلْحَةَ عَنِ ابْنِ عَبَّاسٍ

فِي قَوْلِهِ {الَّذِينَ إِذَا أَصَابَتْهُمْ مُصِيبَةٌ قَالُوا إِنَّا لِلَّهِ وَإِنَّا إِلَيْهِ رَاجِعُونَ أُولَئِكَ عَلَيْهِمْ صَلَوَاتٌ مِنْ رَبِّهِمْ وَرَحْمَةٌ وَأُولَئِكَ هُمُ الْمُهْتَدُونَ} قَالَ أَخْبَرَنَا اللهُ ﷻ أَنَّ الْمُؤْمِنَ إِذَا سَلَّمَ لِأَمْرِ اللهِ وَرَجَعَ فَاسْتَرْجَعَ عِنْدَ الْمُصِيبَةِ كَتَبَ ثَلَاثَ خِصَالٍ مِنَ الْخَيْرِ الصَّلَاةُ وَالرَّحْمَةُ وَتَحْقِيقُ سَبِيلِ الْهُدَى وَقَالَ رَسُولُ اللهِ ﷺ «مَنِ اسْتَرْجَعَ عِنْدَ الْمُصِيبَةِ جَبَرَ اللهُ مُصِيبَتَهُ وَأَحْسَنَ عُقْبَاهُ وَجَعَلَ لَهُ خَلَفًا صَالِحًا يَرْضَاهُ»