Islam cares about the interest and welfare of the Muslim community. Therefore, if the Muslim community needs an Imam to lead them in prayer and to teach them Islamic knowledge, they can give him a salary in return for his time and effort.
Dr. Muzammil H. Siddiqi, former President of the Islamic Society of North America, states: “Many jurists have allowed Imams to receive a salary. A Muslim can pray at any place; he does not have to be present at a particular mosque, but the Imam of the mosque is required to be at a particular mosque on time in order to lead the prayers.
This is called “ilzam ma la yalzam” (requiring what is not required). So, an Imam is not paid for leading the prayer, but for his special time and effort to be at a particular masjid at all times.
However, if someone comes to a masjid and leads a prayer and then asks for money for having led the prayer or stipulates that he will not lead the prayer unless he is paid a certain amount then that is not acceptable. In this case you should find someone who can lead the prayer without charging anything.”