Sahih Muslim , Book 4, Hadith 1141 (USC-MSA) ⓘ
Ibn 'Umar reported: The Messenger of Allah said during the battle of Khaybar: He who ate of this plant, i. e. garlic, should not come to the mosques. In the narration of Zubair, there is only a mention of" battle" and not of Khaybar.
حَدَّثَنَا مُحَمَّدُ بْنُ الْمُثَنَّى، وَزُهَيْرُ بْنُ حَرْبٍ، قَالاَ حَدَّثَنَا يَحْيَى، - وَهُوَ الْقَطَّانُ - عَنْ عُبَيْدِ اللَّهِ، قَالَ أَخْبَرَنِي نَافِعٌ، عَنِ ابْنِ عُمَرَ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَالَ فِي غَزْوَةِ خَيْبَرَ " مَنْ أَكَلَ مِنْ هَذِهِ الشَّجَرَةِ - يَعْنِي الثُّومَ - فَلاَ يَأْتِيَنَّ الْمَسَاجِدَ " . قَالَ زُهَيْرٌ فِي غَزْوَةٍ . وَلَمْ يَذْكُرْ خَيْبَرَ .
also referenced under: Book 5, Hadith 86 (In-Book) & Hadith 561 (Reference)