I heard the Prophet ﷺ say, "Whoever Allah wishes good for, He grants him understanding of the religion. I am only a distributor, and Allah is the One who gives. This nation will continue to stand firm upon the command of Allah, unharmed by those who oppose them, until the command of Allah comes to pass."
سمعت النبي ﷺ يقول: من يرد الله به خيرا يفقه في الدين، وإنما أنا قاسم، والله يعطي، ولن تزال هذه الأمة قائمة على أمر الله لا يضرهم من خالفهم حتى يأتي أمر الله.
Bukhari narrated it in the Book of Knowledge (71), and Muslim in the Book of Zakat (1037), both through the route of Ibn Wahb, from Yunus, from Ibn Shihab, who said, Humayd bin Abdul-Rahman said, "I heard Muawiya delivering a sermon, saying" (and he mentioned something similar). The wording given here is Bukhari's, and Muslim's wording is close to it, except that the last sentence, "And this nation will continue...", is not found in his version.Imam Malik narrated it in the Book of Divine Decree (8), from Yazid bin Ziyad, from Muhammad bin Kaab Qurazi, who said, Muawiya said on the pulpit, "O Allah, there is no preventer for what You have granted, and no granter for what You have prevented, and wealth avails nothing against You. Whomever Allah wishes to grant good, He gives him understanding of the religion. I heard these words from the Messenger of Allah ﷺ on this very pulpit."