All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
When there are travelers and residents, the best among the residents, who is better in reciting the Quran and is more knowledgeable of Fiqh, has more right to lead the prayer. This is applicable unless the ruler or his deputy is among the travelers as he has more right to lead the prayer in this case. Clarifying this, Ash-Shaafi‘i said:
"I like that the Imaam leads others in prayer, whether he is a traveler or resident, and not to deputize others. When he is a traveler, he should order other residents praying behind him to pray in full unless they are knowledgeable of the rulings. When the travelers and residents gather and the ruler is among them, he should lead them in prayer whether he is a traveler or resident. When the ruler is a resident and he appoints another to lead the prayer, to me it is better to appoint a resident. He has to appoint a person who performs the prayer in full. I dislike that he (i.e. the ruler) appoints a traveler to lead the prayer when there are residents praying behind him. When a resident is led by a traveler in prayer, he completes the prayer and is not required to make up for it. When the ruler is not among them, it is better for me that a resident leads them so that the worshippers complete their whole prayer with an Imaam. Travelers should not head to lead the prayer so that the prayer will be completely performed. When a traveler leads the prayer, the prayer is valid and the residents have to pray in full when the former shortens the prayer. When he prays in full, the others' prayer will be valid and complete. When a traveler leads residents in prayer and he prays in full, his prayer is valid for him and for those who pray behind him, whether travelers or residents."