The imam is the leader of a mosque, and thus the leader of a Muslim community, where people come to ask for guidance in spiritual affairs or when they have a question about religion. Typically, especially in more rural places, or, if you will, in historical settings, he is also the most learned and the most experienced person in the community. He leads the prayer, gives advice, tends for his community, trying to solve issues and grievances that one may have in the community, while in the same time being the most knowledgeable about Islam from the community. In most ways, an imam has a similar role to a preacher or a pastor in Christian Protestant denomination, so, if you are more familiar to those kinds of communities, you might draw parallels on how community members treat him.