Abu Hurairah reported,

The Messenger of Allah ﷺ ended the prayer after only two units. Dhul-Yadayn said to him, "Has the prayer been shortened, or have you forgotten, Messenger of Allah?"The Messenger of Allah ﷺ asked, "Is Dhul-Yadayn telling the truth?"The people replied, "Yes."So the Messenger of Allah ﷺ stood and prayed the remaining two units, then gave the closing salutation, then said the takbir and prostrated as he normally would, or longer.

Bukhari 714

Sahih

حدثنا عبد الله بن مسلمة عن مالك بن أنس عن أيوب بن أبي تميمة السختياني عن محمد بن سيرين

عن أبي هريرة

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

البخاري 714صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Adhan
Chapter
If the imam should follow the people's word when he is uncertain
Numbering
Darussalam 714
Bukhari 714