English : Vol. 1, Book 1, Hadith 227
Grading supplied with this record: Hasan (Darussalam)
Narration text is preserved in its supplied Arabic and English. Translated interfaces and reading guides do not add narration translations in other languages.
مَنْ جَاءَ مَسْجِدِي هَذَا لَمْ يَأْتِهِ إِلاَّ لِخَيْرٍ يَتَعَلَّمُهُ أَوْ يُعَلِّمُهُ فَهُوَ بِمَنْزِلَةِ الْمُجَاهِدِ فِي سَبِيلِ اللَّهِ وَمَنْ جَاءَ لِغَيْرِ ذَلِكَ فَهُوَ بِمَنْزِلَةِ الرَّجُلِ يَنْظُرُ إِلَى مَتَاعِ غَيْرِهِ "
It was narrated that Abu Hurairah said:
"I heard the Messenger of Allah say: 'Whoever comes to this mosque of mine, and only comes for a good purpose, such as to learn or to teach, his status is like that of one who fights in Jihad in the cause of Allah. Whoever comes for any other purpose, his status is that of a man who is keeping an eye on other people's property.'"
Full reference and source
English : Vol. 1, Book 1, Hadith 227 Arabic : Book 1, Hadith 232
View source on Sunnah.com (opens in a new tab)