Abdullah bin Arqam reported,

He used to lead his companions in prayer. One day the time for prayer arrived, but he went off to relieve himself and then returned, saying, "I heard the Messenger of Allah ﷺ say, 'When one of you needs to relieve himself, let him do so before the prayer.'"

Azami 1354

Sahih

عن عبد الله بن أرقم

أنه كان يؤم أصحابه، فحضرت الصلاة يوما، فذهب لحاجته ثم رجع، فقال: إني سمعت رسول الله ﷺ يقول: إذا أراد أحدكم الغائط فليبدأ به قبل الصلاة.

الأعظمي 1354صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Purification
Section
Man needing to relieve himself begins with the toilet
Numbering
Jami al-Kamil 1354 (2nd edition)
Azami 1354