Sayyiduna Abdullah bin Amr (may Allah be pleased with them both) narrates that the Messenger of Allah (peace and blessings be upon him) entered the mosque and saw two gatherings. One gathering was supplicating to Allah and turning to Him in longing, and the other was learning and teaching fiqh (understanding of the religion). The Messenger of Allah (peace and blessings be upon him) said: "Both gatherings are upon good, but one of them is better than the other. As for these, they supplicate to Allah and turn to Him in longing; if He wills He gives them and if He wills He withholds from them. As for these, they learn and teach the ignorant, and I was sent only as a teacher; and these are better." Then he (peace and blessings be upon him) came to them and sat with them.
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 13722