Performing Prayer in congregation is a confirmed Sunnah. Many hadiths discuss the virtue and importance of performing Prayer in congregation. Ibn `Umar quoted the Prophet (peace and blessings be upon him) as saying: ““Prayer in congregation is twenty-seven degrees better than praying individually.” ” (Al-Bukhari and Muslim.)
Sheikh Abdul-`Aziz ibn Baz, the late mufti of Saudi Arabia, stated: If a person comes late to the mosque and the people have already prayed, and he finds someone who joined the prayer late still praying, it is prescribed for him to pray with him and to stand on the right of the one who had joined the prayer late, seeking the reward of praying in congregation. The one who joined the prayer late should then intend to lead the other man. There is nothing wrong with that according to the more correct of the two scholarly opinions. Similarly, if he finds a man praying alone after the imam has said the Tasleem, it is prescribed for him to pray with him and to stand on his right, seeking the reward of praying in congregation. When the one who joined the prayer late or the one who was praying alone says the Tasleem, the one who came in last should stand up and complete his Prayer. This is based on the general meaning of the evidence which speaks about the virtue of praying in congregation. It was proven that when the Prophet (peace and blessings be upon him) saw a man who had entered the mosque after the Prayer was over, he said, “If anyone wants to do this man a favour, let him pray with him.” (Abu Dawood)