Narrated by Abī al-ʿAbbās ʿAbdullāh ibn Abbās (رضي الله عنهما) who said: I was behind the Prophet (صلى الله عليه وسلم) one day and he said:
“O young man! Indeed, I shall teach you a few statements: Protect [the orders] of Allāh and He will protect you. Protect [the orders] of Allāh and you shall find Him before you. If you seek aid, then seek it only from Allāh. And know that if this entire ummah was to gather in order to benefit you with a thing, they will not be able to cause you benefit except with that which Allāh has already written for you. And if they were to gather to harm you with something, they would not be able to harm you except with that which Allāh has already written against you. The pens have been lifted. The pages have dried.”1
Imām Ibn Rajab (d. 795 AH) comments:
Know that all the admonishment given in this ḥadīth revolves around a foundation. What has been mentioned before and after it merely branches from this foundation and returns to it.
For truly, if a servant of Allāh realises that he is only afflicted with that which Allāh has already written for him be it good or bad, benefit or harm, and that the efforts of the creation in opposition to the predestined are completely vain, then the servant can truly appreciate that it is Allāh alone who has allowed harm to befall him or a benefit to reach him. He is the Granter and Preventer.
This realisation obligates recognition of the Oneness of his Lord, the Exalted in Might. It obligates obedience to Him alone, and protection of the boundaries He has set. As the one that is worshipped is done so for the purpose of deriving benefit or defending against harm. For this reason, Allāh blames the ones who worship that which can neither benefit nor cause harm, nor avail them in any way.2
So whomever fully acknowledges that it is none other than Allāh who allows that which is beneficial to occur, or for harm to be afflicted, and that He alone is the Granter and the Preventer—then this must obligate one fearing [His punishment] and hoping [for reward] from Him alone. Just as he will love and request his needs from Him alone. He will feel humility before Him and invoke Him alone. Furthermore, he will prioritise His obedience over that of the creation in its entirety while also seeking to protect himself from that which is the cause of His anger, even if he earns the anger of the entire creation. He will also seek aid, request, and invoke only Him whether it be in turbulent times or those of prosperity. This is in contrast to the habit of the polytheists who sincerely invoke Him in hard times but forget Him in times of happiness. Instead, they invoke others to whom they attach perceived benefit. Allāh, the Exalted in Might said:
قُلْ أَفَرَأَيْتُم مَّا تَدْعُونَ مِن دُونِ اللَّهِ إِنْ أَرَادَنِيَ اللَّهُ بِضُرٍّ هَلْ هُنَّ كَاشِفَاتُ ضُرِّهِ أَوْ أَرَادَنِي بِرَحْمَةٍ هَلْ هُنَّ مُمْسِكَاتُ رَحْمَتِهِ ۚ قُلْ حَسْبِيَ اللَّهُ ۖ عَلَيْهِ يَتَوَكَّلُ الْمُتَوَكِّلُونَ
Say, “Then have you considered what you invoke besides Allāh? If Allāh intended me harm, are they removers of His harm; or if He intended me mercy, are they withholders of His mercy?” Say, “Sufficient for me is Allāh; upon Him [alone] rely the [wise] reliers.”
 Authentic: narrated by al-Tirmidhī: 59 and Aḥmad: 288. Graded authentic by al-Tirmidhī and Ibn Rajab. See Jāmiʿ al-ʿUlūm 2:548.
 Translator note: reference is made to the verse:
إِذْ قَالَ لِأَبِيهِ يَا أَبَتِ لِمَ تَعْبُدُ مَا لَا يَسْمَعُ وَلَا يُبْصِرُ وَلَا يُغْنِي عَنكَ شَيْئًا
“[Mention] when he said to his father, “O my father, why do you worship that which does not hear and does not see and will not benefit you at all?”
And the verses:
إِذْ قَالَ لِأَبِيهِ وَقَوْمِهِ مَا تَعْبُدُونَ ﴿٧٠﴾ قَالُوا نَعْبُدُ أَصْنَامًا فَنَظَلُّ لَهَا عَاكِفِينَ ﴿٧١﴾ قَالَ هَلْ يَسْمَعُونَكُمْ إِذْ تَدْعُونَ ﴿٧٢﴾ أَوْ يَنفَعُونَكُمْ أَوْ يَضُرُّونَ ﴿٧٣﴾ قَالُوا بَلْ وَجَدْنَا آبَاءَنَا كَذَٰلِكَ يَفْعَلُونَ
“When he said to his father and his people, “What do you worship?” They said, “We worship idols and remain devoted to them.” He said, “Do they hear you when you supplicate? Or do they benefit you, or do they harm you?” They said, “But we found our fathers doing thus.”
(Al-Shuʿarāʾ, 26: 70-74)
Source: Jāmiʿ al-ʿUlūm 2:577-578
Translated by: Riyāḍ al-Kanadī