The Shulchan Aruch · Orach Chayim
אורח חיים ק״גOrach Chayim 103
Siman 103 of 697 in Orach Chayim — 3 se'ifim
הלכות תפילהLaws of Prayer· siman 103
Se’if 1א׳
הָיָה עוֹמֵד בִּתְפִלָּה וְיָצָא מִמֶּנּוּ רוּחַ מִלְּמַטָּה, מַמְתִּין עַד שֶׁיִּכְלֶה הָרֵיחַ וְחוֹזֵר וּמִתְפַּלֵּל.
One Who Happens to Pass Gas During His Prayer or Sneeze, Containing 3 S'ifim If one was standing in prayer and gas went out from below, one waits until the smell dissipates and then go back and pray.
Se’if 2ב׳
בִּקֵּשׁ לָצֵאת מִמֶּנּוּ רוּחַ מִלְּמַטָּה וְנִצְטַעֵר הַרְבֵּה וְאֵינוֹ יָכוֹל לְהַעֲמִיד עַצְמוֹ, הוֹלֵךְ לְאֲחוֹרָיו אַרְבַּע אַמּוֹת וּמוֹצִיא הָרוּחַ וּמַמְתִּין עַד (מִמֶּנּוּ) שֶׁיִּכְלֶה הָרֵיחַ, וְאוֹמֵר: רִבּוֹן הָעוֹלָמִים, יְצַרְתָּנוּ נְקָבִים נְקָבִים חֲלוּלִים חֲלוּלִים, גָּלוּי וְיָדוּעַ לְפָנֶיךָ חֶרְפָּתֵנוּ וּכְלִמָּתֵנוּ, חֶרְפָּה וּכְלִמָּה בְּחַיֵּינוּ רִמָּה וְתוֹלֵעָה בְּמוֹתֵנוּ, וְחוֹזֵר לִמְקוֹמוֹ וְחוֹזֵר לַמָּקוֹם שֶׁפָּסַק. הַגָּה: וְעַיֵּן לְעֵיל סי' פ"ה. יֵשׁ אוֹמְרִים דְּכָל זֶה מַיְרֵי כְּשֶׁמִּתְפַּלֵּל בְּבֵיתוֹ, אֲבָל כְּשֶׁמִּתְפַּלֵּל בְּצִבּוּר דְּהָוֵי לֵיהּ בִּיּוּשׁ גָּדוֹל, אֵין צָרִיךְ לְהַרְחִיק כְּלָל לַאֲחוֹרָיו וְגַם לֹא יֹאמַר הָרִבּוֹן, רַק מַמְתִּין עַד שֶׁיִּכְלֶה מִמֶּנּוּ הָרֵיחַ, וְכֵן נוֹהֲגִין. (תְּרוּמַת הַדֶּשֶׁן סִימָן ט"ז).
If one had an urge to pass gas from below and is in a lot of discomfort and can't contain oneself, one walks 4 cubits back and passes the gas, waits until the smell dissipates from one, and then says "Master of the world, You created us with many holes and cavities; It is revealed and known before You our disgrace and shame, disgrace and shame in our life, worm and maggot in our death.", and then goes back to one's place and goes back to the place one left off. Gloss: And see above in Siman 85. There are those who say that all this is [referring to] when one is praying in one's home, but when praying with the congregation, where there would be a great embarrassment for oneself [if one were to do as described above], one does not need to distance oneself at all backwards, and one also shouldn't say the "Master [of the worlds]..." [prayer that was mentioned above], rather one should just wait until the smell dissipates from one. And such is how we practice. (Terumat Hadeshen Siman 16).
Se’if 3ג׳
הַמִּתְעַטֵּשׁ בִּתְפִלָּתוֹ מִלְּמַטָּה, סִימָן רַע לוֹ; מִלְּמַעְלָה, סִימָן יָפֶה לוֹ.
One who "sneezes" during [the middle of] one's prayer [i.e. Amidah]: [if it's] from below (i.e. one passes gas), it's a bad sign; [if it's] from above (i.e. a sneeze from one nose), it's a good sign.
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0