كتاب الْمَسَاجِدِ وَمَوَاضِعِ الصَّلاَةِ
5  
The Book of Mosques and Places of Prayer
(19)
Chapter: As-Sahw (forgetfulness) in prayer and prostrating to compensate for it
(19)
باب السَّهْوِ فِي الصَّلاَةِ وَالسُّجُودِ لَهُ ‏
Sahih Muslim 389 i

Abu Huraira reported:

The Messenger of Allah (ﷺ) said: The devil takes to his heels breaking wind when the prayer begins. and the rest is the same but with this addition:" He (the devil) makes him think of pleasant things (or things productive of enjoyment) and of the things wished for, and reminds him of such needs which he had forgotten."
حَدَّثَنِي حَرْمَلَةُ بْنُ يَحْيَى، حَدَّثَنَا ابْنُ وَهْبٍ، أَخْبَرَنِي عَمْرٌو، عَنْ عَبْدِ رَبِّهِ بْنِ سَعِيدٍ، عَنْ عَبْدِ الرَّحْمَنِ الأَعْرَجِ، عَنْ أَبِي هُرَيْرَةَ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَالَ ‏"‏ إِنَّ الشَّيْطَانَ إِذَا ثُوِّبَ بِالصَّلاَةِ وَلَّى وَلَهُ ضُرَاطٌ ‏"‏ ‏.‏ فَذَكَرَ نَحْوَهُ وَزَادَ ‏"‏ فَهَنَّاهُ وَمَنَّاهُ وَذَكَّرَهُ مِنْ حَاجَاتِهِ مَا لَمْ يَكُنْ يَذْكُرُ ‏"‏ ‏.‏
Reference : Sahih Muslim 389i
In-book reference : Book 5, Hadith 106
USC-MSA web (English) reference : Book 4, Hadith 1162
  (deprecated numbering scheme)