Whatever the case, the Sunnah is to pray Taraweeh after âIshaâ, so the qiyaam of Ramadan comes after âIshaâ, but this is naafil, so his praying it with them before âIshaâ is regarded as a naafil prayer between Maghrib and âIshaâ, and praying between Maghrib and âIshaâ is permissible, but it does not count as the qiyaam that is well known in Ramadan. The qiyaam of Ramadan comes after âIshaâ. So this is regarded as a naafil prayer that he did between Maghrib and âIshaâ, and his praying âIshaâ after that is valid. But what is preferable and better is to start with the obligatory prayer, then pray Taraweeh with them. This is what should be done so as to follow the Sunnah as well as performing the obligatory prayer.
If he prayed with them with the intention of offering the obligatory prayer, then when the imam said the salaam at the end of (the two rakâahs of) Taraweeh, then he stood up and completed the obligatory prayer, that would have been acceptable. So if the imam prayed the first two rakâahs with the intention of praying Taraweeh, and he was offering the obligatory prayer, then when the imam said the salaam, he stood up and completed his prayer, that would be acceptable.
To sum up: there is nothing wrong with this, in sha Allah; his prayer is valid, and his Taraweeh is valid, but it is regarded as naafil. It is not Taraweeh and it is not the well known qiyaam of Ramadaan; rather the qiyaam of Ramadan comes after âIshaâ. But what he prayed came before âIshaâ, so it comes under the heading of the naafil prayers which it is mustahabb to offer between Maghrib and âIshaâ.
Shaykh âAbd al-âAzeez ibn Baaz (may Allah have mercy on him)
Fataawa Noor âala al-Darb, 2/903