A funeral procession passed by the Prophet ﷺ, and the people praised the deceased with good words. He said, "It has become certain."Then another passed by, and they spoke ill of the deceased, or said something to that effect. He said, "It has become certain."Someone asked, "Messenger of Allah, you said about this one 'It has become certain,' and about that one 'It has become certain'?"He replied, "The testimony of the people. The believers are Allah's witnesses on earth."
مر على النبي ﷺ بجنازة فأثنوا عليها خيرا، فقال: وجبت ثم مر بأخرى فأثنوا عليها شرا- أو قال غير ذلك- فقال: وجبت فقيل: يا رسول الله قلت لهذا وجبت ولهذا وجبت؟ قال: شهادة القوما، المؤمنونا شهداء الله في الأرض.
Bukhari narrated it in the Book of Testimonies (2642), and Muslim in the Book of Funerals (60:949), both of them through Hammad bin Zayd, and Muslim added others besides him, from Thabit, from Anas, and he related it. The wording given here is Bukhari's. Muslim did not state his own wording but instead referred to the narration of Ibn Ulaya, from Abdul-Aziz bin Suhayb, from Anas, who related it similarly but with a longer wording, in which it mentions that the one who asked the Prophet ﷺ was Umar bin Khattab .