Ruling on the prayer of one who prays a fard prayer behind one who is praying a naafil prayer
Question

                What is the ruling on the prayer of one who prays a fard (obligatory) prayer behind one who is praying a naafil (supererogatory) prayer?
Praise be to Allah.
    Shaykh ‘Abd al-‘Azeez ibn Baaz said: “The ruling is that that 
    is valid, because it was proven that on some of his journeys, the Prophet 
     (peace and blessings of Allaah be upon him) led one group of his 
    companions in praying two rak’ahs of the fear prayer, then he led another 
    group in praying two rak’ahs, so the second prayer was naafil for him. 
    Similarly it was proven in al-Saheehayn from Mu’aadh (may Allaah be pleased 
    with him) that he used to pray the fard of ‘Isha’ with the Prophet  
    (peace and blessings of Allaah be upon him), then he would go and lead his 
    own people in praying their fard prayer, so it would be fard for them and 
    naafil for him. (See Saheeh al-Bukhaari, 701; Saheeh Muslim, 
    465).”                                                                             
    
(Majmoo’ Fataawa 
    al-Shaykh ‘Abd al-‘Azeez ibn Baaz, 
    12/178)                                

    This opinion is the view of Imaam al-Shaafa’i and was 
    narrated in one report from Imaam Ahmad. It was also the view favoured by 
    Shaykh al-Islam Ibn Taymiyah, Shaykh Muhammad ibn Ibraaheem and Shaykh 
    Muhammad ibn ‘Uthaymeen (may Allaah have mercy on them all). See al-Sharh 
    al-Mumti’, 4/358.