Muawiyah (r.a.) reported: The Messenger of Allah said "When Allah wishes good for someone, He bestows upon him the understanding of 'deen' (religion).''
Related by Bukhari and Muslim. Riyah-us-Saliheen hadith 1376
Commentary
Knowledge and understanding of the 'deen' (religion) here stands for the understanding of the Qur'an and the Hadith, religious injunctions, and knowledge of the lawful and the unlawful. This narration highlights the excellence of knowledge and the fact that it is a sign of Allah's Help to the person who possesses it and acts upon it
حدثنا سعيد بن عفير قال حدثنا بن وهب عن يونس عن بن شهاب قال قال حميد بن عبد الرحمن سمعت معاوية خطيبا يقول سمعت النبي صلى الله عليه وسلم يقول :(من يرد الله به خيرا يفقهه في الدين وإنما أنا قاسم والله يعطي ولن تزال هذه الأمة قائمة على أمر الله لا يضرهم من خالفهم حتى يأتي أمر الله).
رواه البخاري