Praise be to Allah.
It is proven from the Messenger (blessings and peace of Allah be upon him) that he encouraged praying Taraweeh in congregation and he said: “Whoever stays with the imam until he leaves, (the reward of) qiyaam al-layl will be written for him.”
Narrated and classed as saheeh by al-Tirmidhi (806); also narrated by Abu Dawood (1375), al-Nasaa’i (1605), and Ibn Maajah (1327). Also classed as saheeh by al-Albaani in Saheeh al-Tirmidhi.
This reward will not be attained by anyone but the one who prays with the imam until he has finished all the prayers. The one who only prays some of the prayer and then leaves is not entitled to the reward promised in this hadeeth, which is that of spending a night in prayer (qiyaam laylah).
Shaykh Ibn Baaz (may Allah have mercy on him) was asked:
If a person prays in Ramadan with someone who prays twenty-three rak‘ahs, but he only prays eleven and does not complete the prayer with the imam, is this action of his in accordance with the Sunnah?
He replied: The Sunnah is to complete the prayer with the imam, even if he prays twenty-three rak ‘ahs, because the Messenger (blessings and peace of Allah be upon him) said: “Whoever stands (in prayer) with the imam until he finishes, Allah will record for him (the reward of) spending a night in prayer.” According to another report: “… The rest of that night.”
It is better for one who is praying behind an imam to stay with him until he finishes, whether he prays eleven rak‘ahs or thirteen or twenty three or whatever. That is preferable, to follow the imam until he finishes. End quote from Majmoo‘ Fataawa Ibn Baaz, 11/325
Shaykh Ibn Jibreen (may Allah have mercy on him) said:
Praying qiyaam in Ramadan is attained by praying part of the night, such as half of it or one third of it, whether that is by praying eleven rak‘ahs or twenty-three. Qiyaam is attained by praying behind the neighbourhood imam until he finishes, even if he finishes within one hour.
Imam Ahmad used to pray with the imam and not leave until he finished, acting in accordance with the hadeeth. And whoever wants to attain this reward has to pray with the imam until he finishes Witr, whether he prays a little or a lot, and whether the time taken is long or short. End quote.
Fataawa al-Shaykh Ibn Jibreen. 24/9
If two imams pray in the mosque, then Taraweeh prayer is the prayer of both the imams, so the one who wants to attain the reward of spending the night in prayer should not leave until the second imam has completed his prayer and leaves.
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) was asked: What about one who prays Taraweeh with the first imam, then leaves and says: I will have (the reward for) praying qiyaam al-layl according to the text of the hadeeth because I started with the imam and finished with him?
He replied: As for his saying, “Whoever stands (in prayer) with the imam until he finishes, Allah will record for him (the reward of) spending a night in prayer”, that is correct.
But if there are two imams in one mosque, is each one of them regarded as independent of the other or is each of them the deputy of the other?
What would seem to be correct is the second understanding – that each of them is the deputy of the other and is complementary to him. Based on this, if two imams pray in the mosque, then these two imams are to be regarded as if they are one imam. So the worshipper should stay until the second imam finishes, because we know that prayer behind the second imam is complementary to prayer behind the first one.
Based on this, what we advise our brothers to do is to follow the imams there in the Haram until they are completely finished. Although some brothers leave when they have prayed eleven rak‘ahs and say that this is the number of rak‘ahs that the Messenger of Allah (blessings and peace of Allah be upon him) prayed, and we agree with them that it is better to follow the number that the Messenger (blessings and peace of Allah be upon him) prayed and no one doubts this, nevertheless I think that there is no reason why the number of rak‘ahs should not be increased. This is not on the basis of turning away from the number chosen by the Prophet (blessings and peace of Allah be upon him), but on the basis that this is part of the goodness that it is prescribed to seek more of.
But the problem is if there are two Witrs in one night, what should the worshipper do?
We say: if you want to pray tahajjud with the second imam, when the first imam prays Witr, do an additional rak‘ahs so that you will be praying two by two, and if you do not want to pray tahajjud at the end of the night, then pray Witr with the first imam, then if it so happens that after that you pray tahajjud, then do another rak‘ah after Witr with the second imam. End quote.
Majmoo‘ Fataawa wa Rasaa’il Ibn ‘Uthaymeen, 13/436
What should be done in this case is that the people of the mosque should agree upon the number of rak‘ahs they will pray each night, which should suit all or most of them, so that there will not be any division among the worshippers and so that none of them will be deprived of reward, which they may be keen to attain were it not for their work.
We ask Allah to accept from us all and help us to obey Him.
And Allah knows best.