The Messenger of Allah ﷺ sent me on an errand, so I went and completed it, then returned. I came to the Prophet ﷺ and greeted him with peace, but he did not return my greeting. Something fell into my heart that only Allah knows about, and I said to myself, "Perhaps the Messenger of Allah ﷺ is displeased that I was slow in returning."Then I greeted him again, but he did not return my greeting, and what fell into my heart this time was worse than the first.Then I greeted him a third time, and this time he returned my greeting and said, "What prevented me from returning your greeting was that I was praying."He was on his mount, facing a direction other than the qiblah.
بعثني رسول الله ﷺ في حاجة له، فانطلقت، ثم رجعت وقد قضيتها. فأتيت النبي ﷺ فسلمت عليه فلم يرد علي. فوقع في قلبي ما الله أعلم به، فقلت في نفسي: لعل رسول الله ﷺ وجد على أني أبطات عليه، ثم سلمت عليه فلم يرد علي، فوقع في قلبي أشد من المرة الأولى. ثم سلمت عليه فرد علي فقال: إنما منعني أن أرد عليك أني كنت أصلي وكان على راحلته متوجها إلى غير القبلة.
Bukhari narrated it in "Actions during Prayer" (1217), and Muslim in "Mosques" (38/540), both through the route of Abdul-Warith bin Saeed, who said, "Kathir bin Shinzir narrated to us, from Ata bin Abu Rabah, from Jabir bin Abdullah," and he related it. The wording given here is Bukhari's.In a narration recorded by Muslim, from Zuhayr, who said, "Abu Zubayr narrated to me, from Jabir," who said, "The Messenger of Allah ﷺ sent me on an errand while he was setting out toward Banu Mustaliq. I came to him while he was praying on his camel. I spoke to him, and he gestured to me with his hand like this." (Zuhayr gestured with his hand.) "Then I spoke to him again, and he gestured to me like this." (Zuhayr again gestured with his hand toward the ground.) "And I could hear him reciting, nodding his head. When he finished, he said, 'What did you do about the matter I sent you for? Nothing kept me from speaking with you except that I was praying.'"