Complex sentence: They believed that any Muslim--even if not Quraysh or even Arab--could be the leader of the community (imam) if he was morally irreproachable, but if the leader sinned, it was the duty of Muslims to oppose and depose him.
Split into simpler sentences: They believed that any Muslim--even if not Quraysh or even an Arab--could be the Imam, the leader of the community, if he was morally irreproachable. If the leader sinned, it was the duty of Muslims to oppose and depose him.