Sheikh Fahd `Abd al-Rahmân Al-Mishal, professor at al-Imâm University
Scholars disagree regarding whether or not the imam and the one following him can have the intention to pray two different obligatory prayers.
The majority of scholars from the Hanafî, Malikî and Hanbalî schools of law hold the view that it is not lawful for the imam and the follower to be praying different obligatory prayers.
The Shafi`î school of law, as well as the scholars Ibn Taymiyyah, Sheikh Muhammad b. Ibrâhîm , `Abd `Azîz b. Baz and Muhammad b. `Uthaymîn believe it is lawful to do so in consideration of the generality of the evidence, and based on the principle that there is no harm if there is a difference of intention between the imam and the one who prays behind him.
For example: If you pray `Isha’ behind an imam praying Maghrib you should pray one more unit after completing the three units. But, if you pray Maghrib behind an imam praying `Isha’ then you have to wait upon completing the third unit until the imam completes his fourth unit, then you complete your prayer by saying salam with him. In this way, your salam will be after the imam’s and you gain the reward of congregational prayer.
Sheikh Bin Baz sees no harm if there is difference in intention between imam and the followers regarding whether the prayer is obligatory or voluntary. The imam may be praying a voluntary prayer while someone who wants to pray an obligatory prayer can follow him.
[For further information see Majmû’ Fatawâ Sheikh `Abd `Aziz b. Baz (12/178) and al-Sharh al-Mumti` by Sheikh Ibn `Uthaymîn (4/364)]
Source: Islam Today