Mishkat al-Masabih 206
وَعَنْ عَبْدِ اللَّهِ بْنِ عَمْرٍو قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «إِنَّ اللَّهَ لَا يَقْبِضُ الْعِلْمَ انْتِزَاعًا يَنْتَزِعُهُ مِنَ الْعِبَادِ وَلَكِنْ يَقْبِضُ الْعِلْمَ بِقَبْضِ الْعُلَمَاءِ حَتَّى إِذَا لَمْ يُبْقِ عَالِمًا اتَّخَذَ النَّاسُ رُءُوسًا جُهَّالًا فَسُئِلُوا فَأَفْتَوْا بِغَيْرِ عِلْمٍ فضلوا وأضلوا»
From ʿAbdullah ibn ʿAmr, who said: The Messenger of Allah ﷺ said: "Allah does not take away knowledge by snatching it from the slaves, but He takes away knowledge by taking away the scholars, until, when He leaves no scholar, people take ignorant leaders, who are asked and give rulings without knowledge, so they go astray and lead astray."