Sahih al-Bukhari — Hadith 832 (KitabGrid sequence)
Narrated Ibn `Umar:
حَدَّثَنَا مُسَدَّدٌ، قَالَ حَدَّثَنَا يَحۡيَى، عَنۡ عُبَيۡدِ اللَّهِ، قَالَ حَدَّثَنِي نَافِعٌ، عَنِ ابۡنِ عُمَرَ ـ رضى الله عنهما ـ أَنَّ النَّبِيَّ صلى الله عليه وسلم قَالَ فِي غَزۡوَةِ خَيۡبَرَ
" مَنۡ أَكَلَ مِنۡ هَذِهِ الشَّجَرَةِ ـ يَعۡنِي الثُّومَ ـ فَلاَ يَقۡرَبَنَّ مَسۡجِدَنَا ".
Translation
Musaddad narrated to us; Yahya narrated to us, from Ubaydullah, who said: Nafi narrated to me, from Ibn Umar رضي الله تعالى عنه, that the Prophet صلى الله عليه وآله وسلم said during the expedition of Khaybar:
Whoever eats of this plant—meaning garlic—must not approach our mosque.