The Messenger of Allah ﷺ used to be in the mosque when the prayer was about to begin. If he saw that the people present were few, he would sit and wait, then pray. If he saw that they had gathered in number, he would pray.In another narration, the Prophet ﷺ would go out to the mosque after the call to prayer. If he saw that the people in the mosque were few, he would sit until he saw a group of them gathered, then he would pray. If he went out and found a group already present, he would have the prayer commenced.
كان رسول الله ﷺ يكون في المسجد حين تقام الصلاة، فإذا رآهم قليلا جلس، ثم صلى، وإذا رآهم جماعة صلى. وفي رواية: أن النبي ﷺ كان يخرج بعد النداء إلى المسجد، فإذا رأى أهل المسجد قليلا جلس، حتى يرى منهم جماعة ثم يصلي، وكان إذا خرج فرأى جماعة أقام الصلاة.
Hakim (1/202) narrated it from Abu Muhammad Ahmad bin Abdullah Muzani, who said, Yusuf bin Musa told us, Mahmud bin Khalid Dimashqi and Dawud bin Rashid told us, saying, Walid bin Muslim told us, Ibn Jurayj told us, from Musa bin Uqba, from Nafi bin Jubayr, from Masud Zarqi, from Ali bin Abu Talib, who said, then he related it. Its chain of transmission is sahih. Hakim said, It is sahih according to the criteria of the two Shaykhs (Bukhari and Muslim), though they did not include it.Bayhaqi (202) narrated it through another route from Ibn Jurayj, who said, Musa bin Uqba told me, from Nafi bin Jubayr, from Masud bin Hakam Zarqi, from Ali bin Abu Talib, that the Prophet ﷺ would go out to the masjid after the call to prayer... the hadith in similar wording.This wording is more sahih, given what has come down from Jabir bin Abdullah in a long hadith recorded by Bukhari (560) and Muslim (646), in which it states that the Prophet ﷺ, whenever he saw that they had gathered, would hasten, and whenever he saw that they were slow, would delay.Masud bin Hakam Zarqi was born during the time of the Prophet ﷺ and was a distinguished man, having standing and dignity in Madinah, and is counted among the eminent and senior of the Tabiin. Istiab (1393).