Abu Hurairah reported,

The Messenger of Allah ﷺ said, "When one of you performs ablution and does it well, then heads to the mosque with nothing motivating him but the prayer and seeking nothing but the prayer, he does not take a single step without Allah raising him a degree by it and erasing a sin from him by it, until he enters the mosque. Once he enters the mosque, he is considered to be in prayer for as long as the prayer is what keeps him there."

Ibn Majah 774

Sahih

حدثنا أبو بكر بن أبي شيبة حدثنا أبو معاوية عن الأعمش عن أبي صالح

عن أبي هريرة قال

قال رسول الله ﷺ إذا توضأ أحدكم فأحسن الوضوء ثم أتى المسجد لا ينهزه إلا الصلاة لا يريد إلا الصلاة لم يخط خطوة إلا رفعه الله بها درجة وحط عنه بها خطيئة حتى يدخل المسجد فإذا دخل المسجد كان في صلاة ما كانت الصلاة تحبسه

ابن ماجه 774صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Mosques and congregations
Chapter
Walking to prayer
Numbering
Darussalam 774
Ibn Majah 774