Hadith 617

It was narrated from Abu Umamah that: The Messenger of Allah forbade a man to perform prayer when he was suppressing (the urge to urinate or defecate).

حَدَّثَنَا بِشْرُ بْنُ آدَمَ، حَدَّثَنَا زَيْدُ بْنُ الْحُبَابِ، حَدَّثَنَا مُعَاوِيَةُ بْنُ صَالِحٍ، عَنِ السَّفْرِ بْنِ نُسَيْرٍ، عَنْ يَزِيدَ بْنِ شُرَيْحٍ، عَنْ أَبِي أُمَامَةَ، أَنَّ رَسُولَ اللَّهِ ـ صلى الله عليه وسلم ـ نَهَى أَنْ يُصَلِّيَ الرَّجُلُ وَهُوَ حَاقِنٌ ‏.‏

Reference: 1306590
In-book reference: Book 1, Hadith 617
Hadith 617 - The Book of the Sunnah - Sunan Ibn Majah - Sunnah.com