Sunan an-Nasa'i, Hadith 852

It was narrated from Hisham bin 'Urwah from his father that 'Abdullih bin Arqam used to lead his companions in prayer. The time for prayer came one day and he went to relieve himself then he came back and said: "I heard the Messenger of Allah say: 'If any one of you feels the need to defecate, let him do that first, before he prays."'

أَخْبَرَنَا قُتَيْبَةُ، عَنْ مَالِكٍ، عَنْ هِشَامِ بْنِ عُرْوَةَ، عَنْ أَبِيهِ، أَنَّ عَبْدَ اللَّهِ بْنَ أَرْقَمَ، كَانَ يَؤُمُّ أَصْحَابَهُ فَحَضَرَتِ الصَّلاَةُ يَوْمًا فَذَهَبَ لِحَاجَتِهِ ثُمَّ رَجَعَ فَقَالَ سَمِعْتُ رَسُولَ اللَّهِ صلى الله عليه وسلم يَقُولُ ‏ "‏ إِذَا وَجَدَ أَحَدُكُمُ الْغَائِطَ فَلْيَبْدَأْ بِهِ قَبْلَ الصَّلاَةِ ‏" ‏ ‏.‏

sunnah.com