I met the Prophet ﷺ while I was in a state of major ritual impurity. I walked along with him until he sat down, then I slipped away, went to my mount, and performed the ritual bath. Then I came back while he was still sitting.He asked, "Where were you?"I replied, "You met me when I was in a state of major impurity, and I disliked sitting with you in that state, so I went and bathed."He said, "Glory be to Allah. The believer is never impure."
حدثنا محمد بن أبي عدي عن حميد عن بكر عن أبي رافع
لقيت النبي ﷺ وأنا جنب فمشيت معه حتى قعد فانسللت فأتيت الرحل فاغتسلت ثم جئت وهو قاعد فقال أين كنت فقلت لقيتني وأنا جنب فكرهت أن أجلس إليك وأنا جنب فانطلقت فاغتسلت قال سبحان الله إن المؤمن لا ينجس
Its isnad is sahih. The six collections narrated it with the same meaning. It appears in Bukhari 1/79, in ghusl, on the sweat of the one in a state of janabah, and that the believer does not become impure, and in Muslim, in menstruation, on the proof that the believer does not become impure, number 115, and Abu Dawud 231, and Tirmidhi 121, both in purification, on shaking hands with one in a state of janabah, and Nasai 1/146, and Ibn Majah 534, and Ibn Abu Shayba 1/173.