The Messenger of Allah (ﷺ) said: “Whoever sees an afflicted person and says:
الحَمْدُ لِلَّهِ الَّذِي عَافَانِي مِمَّا ابْتَلَاكَ بِهِ، وَفَضَّلَنِي عَلَى كَثِيرٍ مِمَّنْ خَلَقَ تَفْضِيلًا
Alhamdu lillahil-ladhi afani mimmab-talaka bihi wa faddalani ala kathirim-mimman khalaqa tafdeela
(Praise be to Allah who had saved me from what He had afflicted you with, and for honouring me over many of his creations)
….He (or she) will never by afflicted by it (this particular affliction).”
Note: The Prophet(ﷺ) would say this du’a without letting the afflicted person hear him, as not to hurt him.
[At-Tirmidhi No 3431 & 3412; Ibn Majah No 3892 and classed as Hasan by al-Albani in Saheeh al-Tirmidhi (3/153). Also see Sahih Al-Kalim Al-Tayeb No 229 & Al-Silsilah al-Saheehah 2/153]
Abu Huraira (رضي الله عنه) said: “‘Whoever sees someone being trialed and says: ‘All Praise to Allah who has pardoned me from that which you have been afflicted with and favoured me above you, and above all of His creation’, then he has indeed given sufficient gratitude (Shukr) for that blessing.’” [Taken from ‘Udat-us-Sabireen’ by Ibn al-Qayyim p.280. Authenticated by Shaykh Al-Albani in Sahih al-Jami ‘as-Saghir 555]
قوله: ((من رأى مبتلى)) أي مبتلى بنوع من الأمراض والأسقام، أو مبتلى بالبعد عن الله تعالى وعن دينه الحنيف.
His saying: (who sees an afflicted person) means the one who is suffering from any kind of diseases and illnesses, or suffering from being distant from Allah and his religion.
قوله: ((وفضلني على كثير ممن خلق)) يجوز أن يكون المراد به الجماعة المبتلون، وتفضيل الله تعالى إياه عليهم، بحيث إنه سلمه من هذا البلاء، الذي ابتلاهم به.
His saying (and preferred me to many of those who created) may be it refers to the group of afflicted people, and Allah’s preferences here is to save him from the affliction befall on them.
وينبغي أن يقول هذا الذكر سراً، بحيث يُسمع نفسه، ولا يُسمعه المبتلى؛ لئلا يتألم قلبه بذلك، إلا أن تكون بليته معصية، فل
This Dua should be said in secret, so that he hears himself, and does not let the one who is affected, hears it in order not to give him a feeling of pain unless his affliction is because of his disobedience.
al-Imam an-Nawawi and others mentioned he shouldn’t raise his voice with the du’a to the extent the person who is afflicted can hear him.
Ash-Shaikh Muhammad bin Abdul-Wahaab (رَحِمَهُ ٱللَّٰهُ) was the one who mentioned it should be said when seeing a person who is afflicted in his religion or body, as found in his book ‘Adaabul Mashee ilaa salaatu’ .
This Dua is said whether the person being afflicted is a Muslim or a non Muslim.
Ibnul Arabi (رَحِمَهُ ٱللَّٰهُ) said when explaining the hadeeth:
قوله من رأى صاحب بلاء أي مبتلي في أمر بدني كبرص وقصر فاحش أو طول مفرط أو عمى أو عرج أو اعوجاج يد ونحوها أو ديني بنحو فسق وظلم وبدعة وكفر وغيرها
“His statement ‘if he sees a person of trials’, (which has the) meaning (of) being trialed in his body, such as with having leprosy, or with being extremely short, or being extremely tall, or being blind, or being crippled, or the shape of his hand is distorted or its likes. (Similarly), or a religious related affliction similar to wrongdoing and oppression, and an innovation and disbelief, and other than it.” [Last part taken from here]