Short answer
Yes. Nothing happens except by Allah's knowledge, will and wisdom, and for a believer every event holds good: gratitude in ease, patience in hardship. You may not see the reason now, and you are not asked to, but Allah does not waste your patience.
Belief that all events happen by Allah's decree is part of iman. Patience (sabr) with what Allah decrees is wajib, and objecting to His decree in anger is haram. Complaining to Allah, as Prophet Yaqub did (12:86), is not against patience.
The four schools agree on this.
Explanation
"No disaster strikes except by permission of Allah. And whoever believes in Allah, He will guide his heart" (64:11). Allah is al-Hakim, the All-Wise. Nothing in your life is random to Him, even when it feels random to you.
The Prophet ﷺ said the affair of the believer is amazing: all of it is good for him. If something good happens he is grateful, and that is good for him; if harm reaches him he is patient, and that is good for him. And that is only for the believer (Sahih Muslim). The good is not always in the event itself. It is in how you meet it.
Often the reason is hidden. "Perhaps you hate a thing and it is good for you; and perhaps you love a thing and it is bad for you. And Allah knows, while you know not" (2:216). The story of Musa and al-Khidr in Surah al-Kahf shows it: a damaged boat and other painful events that Musa could not accept turned out to be mercy (18:79-82).
How to live with this:
- When something hurts, say "Inna lillahi wa inna ilayhi raji'un" (2:156).
- Do not torment yourself with "if only". The Prophet ﷺ said: say instead, "Allah decreed, and what He willed He did."
- Keep taking means for the future. Qadr is for peace about the past, not an excuse about the future.
He also taught Ibn Abbas that if the whole world gathered to benefit you, it could only benefit you with what Allah had written for you. Read What is qadr? and Hadith about patience.
The evidence
Quran, Surah At-Taghaabun 64:11
مَآ أَصَابَ مِن مُّصِيبَةٍ إِلَّا بِإِذْنِ ٱللَّهِ ۗ وَمَن يُؤْمِنۢ بِٱللَّهِ يَهْدِ قَلْبَهُۥ ۚ وَٱللَّهُ بِكُلِّ شَىْءٍ عَلِيمٌۭ ﴿١١﴾
No disaster strikes except by permission of Allah. And whoever believes in Allah - He will guide his heart. And Allah is Knowing of all things.
All events happen by Allah's permission.
Quran, Surah Al-Baqara 2:216
كُتِبَ عَلَيْكُمُ ٱلْقِتَالُ وَهُوَ كُرْهٌۭ لَّكُمْ ۖ وَعَسَىٰٓ أَن تَكْرَهُوا۟ شَيْـًۭٔا وَهُوَ خَيْرٌۭ لَّكُمْ ۖ وَعَسَىٰٓ أَن تُحِبُّوا۟ شَيْـًۭٔا وَهُوَ شَرٌّۭ لَّكُمْ ۗ وَٱللَّهُ يَعْلَمُ وَأَنتُمْ لَا تَعْلَمُونَ ﴿٢١٦﴾
Fighting has been enjoined upon you while it is hateful to you. But perhaps you hate a thing and it is good for you; and perhaps you love a thing and it is bad for you. And Allah Knows, while you know not.
The wisdom of events can be hidden from us.
Quran, Surah Yusuf 12:86
قَالَ إِنَّمَآ أَشْكُوا۟ بَثِّى وَحُزْنِىٓ إِلَى ٱللَّهِ وَأَعْلَمُ مِنَ ٱللَّهِ مَا لَا تَعْلَمُونَ ﴿٨٦﴾
He said, "I only complain of my suffering and my grief to Allah, and I know from Allah that which you do not know.
Complaining to Allah does not contradict patience.
Sahih Muslim 2999
Sahih... عجبا لأمر المؤمن إن أمره كله خير ...
"How amazing is the affair of the believer: all of it is good for him."
For a believer, every event holds good.
Sahih Muslim 2664
Sahih... ولكن قل قدر الله وما شاء فعل ...
"But say: Allah decreed, and what He willed He did."
The sunnah response to a setback instead of 'if only'.
Jami' at-Tirmidhi 2516
Grading to be checked... واعلم أن الأمة لو اجتمعت على أن ينفعوك ...
"Know that if the whole nation gathered to benefit you, they could only benefit you with what Allah has written for you."
Nothing reaches a person except what Allah decreed.
Where the ruling is recorded
- al-Aqida al-Tahawiyya, Section on the decree. Teaches that what reached you could not have missed you, and what missed you could not have reached you.
- Ihya Ulum al-Din (al-Ghazali), Kitab al-Sabr wa al-Shukr. Explains patience with the decree and what breaks it.
Checked by our team. For a more accurate answer to your own situation, consult a scholar. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.