Sunan Ibn Majah, Book 1, Hadith 351 (Ibn Majah 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).