the Sacred Mosque in Mecca and the Prophet’s Mosque in Medina.
But if neither mosque has any distinguishing virtue, then a person’s prayer in his local mosque is preferable, because this helps keep it active, fosters harmony with the imam and the people of the neighborhood, and prevents any ill feeling the imam may have if you do not pray with him—especially if you are a man of standing.
As for the more distant mosque, the hadith may be understood to refer to a mosque when there is no nearer mosque than it. In that case, the farther away the mosque is, and the more one exerts himself to go to it despite its distance, the better it is without doubt than if it were nearby. For whenever an act of worship is more difficult, provided it cannot be performed by an easier means, it is more virtuous. As the Prophet, peace and blessings be upon him, said to Aisha: “Your reward is commensurate with your hardship.” (2)
In summary, it is preferable to pray in the mosque of the neighborhood in which you live, whether its congregation is larger or smaller, because of the benefits that result from this. Next comes the mosque with the larger congregation, due to his saying, peace and blessings be upon him: “Whatever is greater is more beloved to Allah.” (3) Then comes the more distant mosque, followed by the older mosque, because giving preference to a place on the basis that acts of worship were performed there earlier requires clear evidence, and there is no clear evidence on this matter.