The Prophet ﷺ was sitting one day in full view of the people when a man came to him and asked, "What is faith?"He replied, "Faith is to believe in Allah, His angels, His Book, the meeting with Him, His messengers, and to believe in the final resurrection."The man asked, "Messenger of Allah, what is Islam?"He replied, "Islam is to worship Allah without associating anything with Him, to establish the prescribed prayer, to pay the obligatory zakat, and to fast Ramadan."The man asked, "Messenger of Allah, what is excellence?"He replied, "It is to worship Allah as though you see Him, for though you do not see Him, He sees you."The man asked, "Messenger of Allah, when is the Hour?"He replied, "The one being asked knows no more about it than the one asking. But I will tell you of its signs. When a slave woman gives birth to her mistress, that is one of its signs. When the barefoot and naked become leaders of the people, that is one of its signs. When the herdsmen of black camels compete in raising tall buildings, that is one of its signs. It is among five things which none knows except Allah."Then he recited, "Indeed, Allah has knowledge of the Hour and sends down the rain and knows what is in the wombs. And no soul perceives what it will earn tomorrow, and no soul perceives in what land it will die. Indeed, Allah is Knowing and Acquainted." [Luqman 31:34]Then the man turned away. The Messenger of Allah ﷺ said, "Bring the man back to me."They went to bring him back, but they saw nothing. So the Messenger of Allah ﷺ said, "That was Jibreel. He came to teach the people their religion."
كان النبي ﷺ بارزا يوما للناس، فأتاه رجل فقال: ما الإيمان؟ قال: الإيمان أن تؤمن بالله، وملائكته وكتابه ولقائه، ورسله، وتؤمن بالبعث الآخر. قال يا رسول الله: ما الإسلام؟ قال: الإسلام أن تعبد الله ولا تشرك به، وتقيم الصلاة المكتوبة، وتؤدي الزكاة المفروضة، وتصوم رمضان. قال يا رسول الله: ما الإحسان؟ قال: أن تعبد الله كأنك تراه فإنك إن لا تراه فإنه يراك. قال يا رسول الله: متى الساعة؟ قال: ما المسؤول عنها بأعلم من السائل، ولكن سأحدثك عن أشراطها؛ إذا ولدت الأمة ربها فذاك من أشراطها، وإذا كانت العراة الحفاة رؤوس الناس فذاك من أشراطها، وإذا تطاول رعاة الإبل البهم في البنيان، فذاك من أشراطها، في خمس لا يعلمهن إلا الله، ثم تلا: {إن الله عنده علم الساعة وينزل الغيث ويعلم ما في الأرحام وما تدري نفس ماذا تكسب غدا وما تدري نفس بأي أرض تموت إن الله عليم خبير}[سورة لقمان: ٣٤] ثم أدبر الرجل، فقال رسول الله ﷺ: ردوا علي الرجل فأخذوا ليردوه فلم يروا شيئا! فقال رسول الله ﷺ: هذا جبريل جاء ليعلم الناس دينهم.
Bukhari narrated it in the tafsir (4777), and Muslim in the faith (9), both of them through Abu Hayan, from Abu Zura bin Amr bin Jareer, from Abu Hurairah, who related it. The wording given is that of Muslim, and Bukhari's wording is similar.