It was narrated that Abu Hurairah said:
"The Messenger of Allah said, 'No one of you should stand to pray when he feels some discomfort (because of needing to urinate or defecate).'" (RU)
English reference (RU): Vol. 1, Book 1, Hadith 618 (RU)
Arabic reference (RU): Book 1, Hadith 661 (RU)