When one wears tefillin, one should have a guf naki. Does this mean a complete urge to go the bathroom or just a slight urge? What if someone puts on tefillin or prays, and only after he must go the bathroom is his prayers invalid? What’s the criteria for a guf naki? Does it only apply to tefillin? Please clarify.
The concept of a guf naki applies both to prayer and to tefillin. A person should not daven if he cannot keep a guf naki, meaning that he has a stomach condition whereby he knows that he will not be able to prevent himself from flatulence. The same principle applies to tefillin.
If a person needs to go to the bathroom, he is forbidden from davening, but there is no obligation to remove one’s tefillin. If the urge is only slight, one should not daven, but the prayer is valid post factum. If he only needs to go to the bathroom after he prays, the prayer is valid.
Sources: See Shulchan Aruch and Mishnah Berurah, Orach Chaim 80.