Shaikh Muqbil rahimahullah was asked:
Question: If I pray in a masjid where the Imam prayers twenty rakat, should I complete twenty with him following the Imam or should I pray with him eight rakah and pray witr alone then leave?
Answer: “I advise that you pray eight rakah and pray witr alone. Following the Sunnah is more deserving for verily the Prophet (ﷺ) said:
صَلُّوا كَمَا رَأَيْتُمُونِي أُصَلِّي
And pray as you have seen me pray
[Reported al-Bukhari no. 6008]
[Fasaa’ih wan-Nasaa’ih pg. 86]
Shaikh al-Albani rahimahullah was asked:
Question: With us in Madinah, O Shaikh, are those who pray in masjid nabawi in three groups…the first group prays eight rak’aat, however the Imam is not finished [when they leave]. The second group prays ten raka’aat then leaves with the first Imam who prays the fard and ten rak’aat. So they leave with him. The third group prays with the second Imam the entire twenty rak’aat and witr. They ask us saying that we did not finish the Qiyaam with the Imam as in the Hadith. We said to them: if the Imam leaves, we leave with the Imam. I don’t know your opinion on this?
Shaikh: “No doubt that the best group or sect of these three is the moderate one. The best of affairs is the moderate one who prays ten and leaves with the Imam when he leaves. They are better than those who pray eight. I do not know why these people pray eight raka’aat because what is necessitated is that these people who leave do so because they do not see that taraweeh is twenty rak’aat. However, why don’t they pray ten raka’aat then pray witr as one? I do not know their point of view on this. What is most correct is the third form and no doubt the moderate one as I mentioned recently…”
The Shaikh goes on to say later:
“…So we say that the Imam mentioned [in the Hadith] “until the Imam leaves”, I said this in the beginning of the speech, however I will emphasis it, that the Imam mentioned in the Hadith is the Imam that follows the Sunnah not the one who opposes. yes” [Silsilatul-Huda wan-Nur no. 254]
Faisal Ibn Abdul Qaadir Ibn Hassan