عَنْ عُقْبَةَ بْنِ عَامِرٍ رَضِيَ اللَّهُ عَنْهُ قَالَ: سَمِعْتُ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَآلِهِ وَسَلَّمَ يَقُولُ: ((إِذَا تَوَضَّأَ الرَّجُلُ فَأَتَى الْمَسْجِدَ كَتَبَ اللَّهُ عَزَّ وَجَلَّ لَهُ بِكُلِّ خُطْوَةٍ يَخْطُوها عَشْرَ حَسَنَاتٍ، فَإِذَا صَلَّى فِي الْمَسْجِدِ ثُمَّ قَعَدَ فِيهِ كَانَ كَالصَّائِمِ الْقَانِتِ حَتَّى يَرْجِعَ))
It is narrated from Sayyiduna Uqbah bin Amir (may Allah be pleased with him), he says: I heard the Messenger of Allah (peace and blessings be upon him) say: "When a servant performs ablution and comes to the mosque, Allah Almighty writes ten good deeds for each step he takes. Then, when he prays in the mosque and sits there, he is like one who fasts and stands in prayer, until he returns."