Bulugh al-Maram, Book 16, Hadith 1565 (English)

Mu’awiyah (RAA) narrated that the Messenger of Allah said: “When Allah wishes good for anyone, He bestows upon him the Fiqh (comprehension) of the religion.” Agreed upon.

وَعَنْ مُعَاوِيَةَ ‏- رضى الله عنه ‏- قَالَ: قَالَ رَسُولُ اَللَّهِ ‏- صلى الله عليه وسلم ‏-{ مَنْ يُرِدِ اَللَّهُ بِهِ خَيْرًا, يُفَقِّهْهُ فِي اَلدِّينِ } مُتَّفَقٌ عَلَيْهِ.‏ (1984)‏.‏ ‏1 ‏- صحيح.‏ رواه البخاري (71)‏، ومسلم (1037)‏.‏

sunnah.com

also referenced under: Book 16, Hadith 1522 (In-Book)