Sahih Muslim Book 4, Hadith Number 1141.

Chapter : When food is brought before man and he is inclined to take it, he should not say prayer before eating it and undesirability of prayer while feeling the call of nature.

Ibn ‘Umar reported: The Messenger of Allah (may peace be upon him) 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.