Hadithcore
Sahih al-Bukhari, 722
sahih

Narrated Abu Huraira:

The Prophet (ﷺ) said, "The Imam is (appointed) to be followed. So do not differ from him, bow when he bows, and say, "Rabbana-lakal hamd" if he says "Sami`a l-lahu liman hamidah"; and if he prostrates, prostrate (after him), and if he prays sitting, pray sitting all together, and straighten the rows for the prayer, as the straightening of the rows is amongst those things which make your prayer a correct and perfect one. (See Hadith No. 657).

حَدَّثَنَا عَبْدُ اللَّهِ بْنُ مُحَمَّدٍ، قَالَ حَدَّثَنَا عَبْدُ الرَّزَّاقِ، قَالَ أَخْبَرَنَا مَعْمَرٌ، عَنْ هَمَّامٍ، عَنْ أَبِي هُرَيْرَةَ، عَنِ النَّبِيِّ صلى الله عليه وسلم أَنَّهُ قَالَ ‏

‏ إِنَّمَا جُعِلَ الإِمَامُ لِيُؤْتَمَّ بِهِ فَلاَ تَخْتَلِفُوا عَلَيْهِ، فَإِذَا رَكَعَ فَارْكَعُوا، وَإِذَا قَالَ سَمِعَ اللَّهُ لِمَنْ حَمِدَهُ‏.‏ فَقُولُوا رَبَّنَا لَكَ الْحَمْدُ‏.‏ وَإِذَا سَجَدَ فَاسْجُدُوا، وَإِذَا صَلَّى جَالِسًا فَصَلُّوا جُلُوسًا أَجْمَعُونَ، وَأَقِيمُوا الصَّفَّ فِي الصَّلاَةِ، فَإِنَّ إِقَامَةَ الصَّفِّ مِنْ حُسْنِ الصَّلاَةِ ‏

‏‏.‏

References2 variants
In-Book Reference
Book 10, Hadith 116
USC-MSA web (English) reference
Vol. 1, Book 11, Hadith 689 (deprecated numbering scheme)
Sharh · explanationclick to expand
There are rules and regulations for offering the prayer in congregation, that the Muslim should pay attention to and learn. One of the most important of these rules is following the imam properly. In this hadith, the Prophet (blessings and peace of Allah be upon him) explains that the imam is only appointed to be followed, so the one who is praying behind the imam should follow his actions in prayer. Therefore the Prophet (blessings and peace of Allah be upon him) forbade those who are praying behind an imam to differ from the imam, which means doing the actions of prayer before him, or being too slow in following him, because differing from the imam means that one is no longer regarded as following him. Then the Messenger of Allah (blessings and peace of Allah be upon him) began to explain in detail, after speaking in general terms, how one should follow the imam. Hence he said: “When he bows, then bow.” The word fa, translated here as “then”, indicates that these actions should be done straight after the imam does them, and that the one who is praying behind the imam should not do them before the imam; rather every action that the one who is praying behind the imam does should be done after the imam does it. When the imam says after bowing, Sami‘a Allahu liman hamidah (Allah hears those who praise Him), then say Rabbana laka al-hamd (our Lord, to You be praise); what is meant is: O our Lord, to You be all praise. This is one of the greatest expressions of supplication and gratitude to Allah (may He be glorified and exalted). Based on that, it is sufficient for the one who is praying behind an imam to say the tahmid (Rabbana laka al-hamd) and not the tasmi‘ (Sami‘a Allahu liman hamidah) when rising from bowing. When the imam prostrates, then prostrate straight after he prostrates. And if he prays sitting, then pray sitting, all of you, for following the imam also means praying sitting if the imam prays sitting. Then the Messenger of Allah (blessings and peace of Allah be upon him) enjoined straightening the rows when praying, meaning that the people should stand in a straight line. This meaning also includes filling the gaps in the rows; the Prophet (blessings and peace of Allah be upon him) gave the reason for this command as being that making the rows straight is part of praying properly. This hadith instructs the worshipper to follow the imam, and not do anything before he does it, or do something different to what he is doing. It also instructs the worshippers to straighten the rows when offering a congregational prayer..
Related hadiths12
Compare isnād across 12 related chains →