كتاب الْمَسَاجِدِ وَمَوَاضِعِ الصَّلاَةِ
5  
The Book of Mosques and Places of Prayer
(50)
Chapter: The virtue of taking many steps to the masjid
(50)
باب فَضْلِ كَثْرَةِ الْخُطَا إِلَى الْمَسَاجِدِ ‏
Sahih Muslim 664

Jabir b. 'Abdullah narrated:

Our houses were situated far away from the mosque; we, therefore, decided to sell our houses so that we may be able to come near the mosque. The Messenger of Allah (ﷺ) forbade us (to do so) and said: There is for every step (towards the mosque) a degree (of reward) for you.
وَحَدَّثَنَا حَجَّاجُ بْنُ الشَّاعِرِ، حَدَّثَنَا رَوْحُ بْنُ عُبَادَةَ، حَدَّثَنَا زَكَرِيَّاءُ بْنُ إِسْحَاقَ، حَدَّثَنَا أَبُو الزُّبَيْرِ، قَالَ سَمِعْتُ جَابِرَ بْنَ عَبْدِ اللَّهِ، قَالَ كَانَتْ دِيَارُنَا نَائِيَةً عَنِ الْمَسْجِدِ، فَأَرَدْنَا أَنْ نَبِيعَ، بُيُوتَنَا فَنَقْتَرِبَ مِنَ الْمَسْجِدِ فَنَهَانَا رَسُولُ اللَّهِ صلى الله عليه وسلم فَقَالَ ‏ "‏ إِنَّ لَكُمْ بِكُلِّ خُطْوَةٍ دَرَجَةً ‏"‏ ‏.‏
Reference : Sahih Muslim 664
In-book reference : Book 5, Hadith 351
USC-MSA web (English) reference : Book 4, Hadith 1406
  (deprecated numbering scheme)