Assalamualaikum ustaz. What is the ruling if a temporary resident man acts as the imam to a traveller and vice versa?
Waalaikumussalam wrt. wbt.,
Alhamdulillah, praise and gratitude to Allah SWT for His countless blessings for us all. Praise and salutations to our beloved Prophet Muhammad PBUH, his family, companions, and all those who follow his footsteps until the Final day.
Among the blessings Allah SWT give to this ummah is to perform prayer through qasar which means to shorten the prayer from four rakaat to two rakaat and two prayers can also be combined (gathered) at one time. Combining between the Zohor and Asar prayers and between Maghrib and Isyak prayers. It is known as Jamak. These two facilitations are permissible especially when one is travelling.
Qasar and jamak prayers are rukhsah given by Allah SWT. It is a facilitation gifted to the Muslim ummah so that they can perform the worship of prayer anywhere they are. This is stated by Allah SWT in his statement:
وَإِذَا ضَرَبْتُمْ فِى ٱلْأَرْضِ فَلَيْسَ عَلَيْكُمْ جُنَاحٌ أَن تَقْصُرُوا۟ مِنَ ٱلصَّلَوٰةِ
“And when you travel throughout the land, there is no blame upon you for shortening the prayer,” 
The above verse explains the rukhsah which is a facilitation and ease given by Allah SWT to his slaves who are travelling. This facilitation (rukhsah) is a gift from Allah to His slaves, then we should graciously accept them. Saidina Umar RA once asked this matter to Rasullullah PBUH, the Prophet PBUH replied:
صَدَقَةٌ تَصَدَّقَ اللَّهُ بِهَا عَلَيْكُمْ ، فَاقْبَلُوا صَدَقَةَ اللَّهِ.
“It is an act of charity which God has done to you, so accept His charity.” 
Syeikh ‘Abd al-Muhsin al-‘Abbad said: “Thus, it is permissible for a traveller to shorten his prayer of four rakaat to two rakaat as well as jamak the zohor with asar prayers and maghrib and isyak prayers. This is the charity to us all.” 
Syeikh Dr Wahbah al-Zuhaili when commenting on the wisdoms of the rukhsah of qasar and jamak is to reject the hardships of travels and ease the obligation of prayer. 
Travel Prayer Following a Resident Imam and Vice Versa
Coming back to the above question, first and foremost, we should clarify what is meant by a traveller and a resident. Hence, we cite the definitions of both of them as stated in the book al-Fiqh al-Manhaji (1/187) as the following:
Traveller: A traveller means a person who is on a journey of more than 2 marhalah or 81 kilometres.
Such safar (journey), must fulfil the following characteristics:
- It is a permissible journey and not for sinful matters.
- It has a good purpose such as going on a business trip and others.
Temporary Resident: A person who stays at one place for more than three days excluding the day he arrives and leaves.
Coming back to the question presented, we divide it into two parts:
First: The prayer of a traveller following a temporary resident imam
In this issue, it is permissible for a traveller to follow a temporary resident imam.
If the traveller enters a mosque or surau and there is a congregational prayer being performed, then he should follow the congregational prayer even if he is a traveller.
If he is in a muwafiq situation and follows the prayer at the beginning and the imam is performing tamam (pray the full four rakaat), then he should follow the imam until the prayer is completed. This is based on a hadith narrated by Anas bin Malik RA, where Rasullullah PBUH said:
إِنَّمَا جُعِلَ الإِمَامُ ـ لِيُؤْتَمَّ بِهِ، فَإِذَا كَبَّرَ فَكَبِّرُوا، وَإِذَا رَكَعَ فَارْكَعُوا، وَإِذَا رَفَعَ فَارْفَعُوا
“The Imam is to be followed; if he says Takbir then say Takbir, bow if he bows; raise your heads when he raises his head,” 
Likewise, according to a narration from Ibn Abbas RA, he was asked: “Why is it a traveller performs two rakaat prayers when he is alone and four rakaat when he follows an imam who is a resident?” Then Ibn Abbas answered: “Such is the sunnah.” 
While if he (a traveller) is in a masbuq situation, where he is late for several rakaat from the imam, hence, if the imam has finished his prayer and gives salam, then he should stand up and continue and complete his prayer in tamam since he is a traveller who follows an imam who performed tamam.
Syeikh Dr Muhammad al-Zuhaili said: “If a traveller follows a resident imam who will usually perform the prayer in tamam (full/complete). The reason is it is an obligatory prayerto be fulfilled (in full).”
He further said: If (a traveller) follows a traveller imam and he is ignorant (doesn’t know) the intention of the imam (whether it is tamam or qasar) then he can ta’liq (bind) his intention. Which is with: “If he (imam) qasar then I’ll perform qasar and if he prays tamam (pray the complete four rakaat), then I’ll also perform tamam.”
According to the most sahih opinion, his ta’liq is valid. Hence, the imam performs tamam then he should also perform tamam and if the imam performs qasar then, he should also perform qasar. The reason is the apparent situation for a traveller is qasar. 
Second: A resident following a traveller imam
In this issue there is a narration which can be made as our guidance and reference. This is based on a hadith narrated by Imran bin Husain, he said:
غَزَوْتُ مَعَ رَسُولِ اللَّهِ صلى الله عليه وسلم وَشَهِدْتُ مَعَهُ الْفَتْحَ فَأَقَامَ بِمَكَّةَ ثَمَانِيَ عَشْرَةَ لَيْلَةً لاَ يُصَلِّي إِلاَّ رَكْعَتَيْنِ وَيَقُولُ يَا أَهْلَ الْبَلَدِ صَلُّوا أَرْبَعًا فَإِنَّا قَوْمٌ سَفْرٌ
“I went on an expedition with the Prophet, and I was present with him at the Conquest. He stayed eighteen days in Mecca and prayed only two rak’as [at each time of prayer]. He said, “You who live in the town must pray four; we are travellers.” 
According to the fiqh of the above hadith, it can be understood that a person who isn’t travelling is permissible to follow a traveller imam. However, he should still perform the four rakaat by completing the remaining rakaat after the traveller imam has finished his prayer of two rakaat (through qasar).
Furthermore, this matter is considered as ijma’ by scholars. This is stated by Imam Ibn al-Munzir:
وأَجمَعُوا عَلَى أَنَّ المُقِيمَ إِذَا ائْتَمَّ بِالمُسَافِرِ، وَسَلَّمَ الإمَامُ رَكْعَتَين أَنَّ عَلَى المُقِيمِ إِتمَام الصَّلَاة
“And they (the scholars) agreed that a resident when he is the makmum of a traveller imam when the imam finishes his prayer and gives salam at the second rakaat, then the resident makmum should complete his prayer.” 
To close, the ruling of a traveller to act as the imam to a resident makmum is permissible. Hence, it is also permissible for a resident to be the imam for a traveller. This is based on the narrations and arguments that we’ve presented above, as well as celebrating the methodology and conditions set.