Shaikh Ibn ul-‘Uthaymeen (may Allah have mercy upon him) was asked:
“A group of people entered the masjid before the prayer was established and prayed before the Iqamah was called. What is the ruling on their prayer?
“It is not allowed for people to establish a congregational prayer in the masjid that has a fixed Imam except with the permission of the Imam. If they say we are travelers and we cannot wait until the Imam comes and prays, then we say the matter is spacious. If they are travelers, then travel and pray on the way. As for praying in the masjid which has a fixed Imam before he attends, then this is not allowed. This is because the Prophet (ﷺ) prohibited that. He (ﷺ) said:
وَلاَ يَؤُمُّ الرَّجُلُ الرَّجُلَ فِي سُلْطَانِهِ
A man should not be led in prayer in his place of authority
So the authority of the masjid is its Imam, So it is obligatory to wait until he appears. If they were to say we are travelers and we cannot wait, we say All praise is due to Allah. You are excused for leaving off the congregation. So travel and pray whereever you want”. End translation. [Reference]
So if one has to pray, then it’s better he pray in another masjid or mussalah where there is no fixed imam.
Faisal bin Abdul Qaadir bin Hassan