Mishkat al-Masabih 213, 214
Abu Umama al-Bahili said that:
Two men, one learned and the
other devout, were mentioned to God’s messenger, who then said, “The
superiority of the learned man over the devout man is like mine over
the most contemptible among you,” adding, “God, His angels, the inhabitants of the heavens and the earth, even the ant in its hole and even
the fish invoke blessings on him who teaches men what is good.”
Tirmidhi transmitted it. 

Darimi transmitted it from Makhul in mursal form, but did not mention the two men. He said, “The superiority of
the learned man over the devout man is like mine over the most contemptible among you.” Then he recited this verse, “Only those of His
servants who are learned fear God," (35:28) 1 then went on with the tradition to
the end.
وَعَن أبي أُمَامَة الْبَاهِلِيّ قَالَ: " ذُكِرَ لِرَسُولِ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ رَجُلَانِ أَحَدُهُمَا عَابِدٌ وَالْآخَرُ عَالِمٌ فَقَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «فَضْلُ الْعَالِمِ عَلَى الْعَابِدِ كَفَضْلِي عَلَى أَدْنَاكُمْ» ثُمَّ قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «إِنَّ اللَّهَ وَمَلَائِكَتَهُ وَأَهْلَ السَّمَاوَاتِ وَالْأَرْضِ حَتَّى النَّمْلَةَ فِي جُحْرِهَا وَحَتَّى الْحُوتَ لَيُصَلُّونَ عَلَى معلم النَّاس الْخَيْر» . رَوَاهُ التِّرْمِذِيّ وَقَالَ حسن غَرِيب
وَرَوَاهُ الدَّارِمِيُّ عَنْ مَكْحُولٍ مُرْسَلًا وَلَمْ يَذْكُرْ: رَجُلَانِ وَقَالَ: فَضْلُ الْعَالِمِ عَلَى الْعَابِدِ كَفَضْلِي عَلَى أَدْنَاكُمْ ثُمَّ تَلَا هَذِهِ الْآيَةَ: (إِنَّمَا يخْشَى الله من عباده الْعلمَاء)