Allah's Messenger said: "When one of you is in the Masjid, and he senses wind between his buttocks then he should not exit until he hears a sound or smells an odor."
Jami` at-Tirmidhi Book 1, Hadith 75