Abu Hurairah reported,

The Messenger of Allah ﷺ came out after the prayer had been called and the rows had been straightened. When he stood at his prayer spot, we waited for him to say the opening takbir, but he turned away and said, "Stay in your places."So we remained as we were until he came back out to us with water dripping from his head, having bathed.

Bukhari 639

Sahih

حدثنا عبد العزيز بن عبد الله قال حدثنا إبراهيم بن سعد عن صالح بن كيسان عن ابن شهاب عن أبي سلمة

عن أبي هريرة

أن رسول الله ﷺ خرج وقد أقيمت الصلاة وعدلت الصفوف حتى إذا قام في مصلاه انتظرنا أن يكبر انصرف قال على مكانكم فمكثنا على هيئتنا حتى خرج إلينا ينطف رأسه ماء وقد اغتسل

البخاري 639صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Adhan
Chapter
Leaving the masjid for a reason
Numbering
Darussalam 639
Bukhari 639