Answer: The one who leads the Muslims in prayer must possess sound creed together with exemplary conduct and deeds, for he serves as a model and the office of leading the prayer is a tremendous trust and a weighty responsibility. Accordingly, if the imam you describe is given to practices of associationism, superstition, or innovation, it is not valid to pray behind him. Whoever believes that benefit or harm can come from anything other than Allah—whether from graves or from the dead—has fallen into major associationism. And if he seeks nearness to graves through offerings such as animal sacrifice, vows, supplication, or the like, that too is major associationism whose perpetrator has left Islam; none of his acts of worship are acceptable so long as he clings to that false creed.
Likewise, if he engages in innovations or superstitions that do not rise to the level of associationism, such conduct still undermines his probity and disqualifies him from leading the prayer, for an imam must be upright. These innovations and superstitions blemish his integrity, rendering him unfit to serve as imam and invalidating the prayer behind him.
As for the congregation: when the imam’s creed, behavior, and character are sound and he is upright, the prayer behind him is valid even if some worshippers in the rows commit associationism, innovation, or superstition. What counts is the imam whose leadership renders the prayer valid, regardless of the faults found among some of those praying behind him.
However, if it is the imam himself who practices those acts of associationism or innovation, then, as stated, the prayer behind him is invalid. In that case you must seek another mosque whose imam is upright, sound in creed, and righteous in deed.