Sayyiduna Jabir (may Allah be pleased with him) narrates: The Prophet Muhammad (peace and blessings be upon him) forbade people from eating garlic, but people did not refrain from it. They had no choice but to eat it. When the Prophet (peace and blessings be upon him) sensed its smell, he said: Did I not forbid you from this foul vegetable (the narrator is in doubt, perhaps these are the words) — this odorous vegetable? Whoever eats it should not come to our mosques, because the angels are harmed by that which harms human beings.
Hadith Referenceصحیح ابن حبان / كتاب الصلاة / 1646
Hadith Gradingفضيلة الشيخ الإمام محمد ناصر الدين الألبانيصحيح - انظر ما قبله.فضيلة الشيخ العلّامة شُعيب الأرناؤوطرجاله ثقات رجال الشيخين، إلا أن فيه تدليس ابن جريج وأبي الزبير.