Is it permissible for a man who lives among a community of people who invoke help from other than Allah to perform Salah (prayer) behind them (when they lead the congregational prayers)?
Is it obligatory to disassociate oneself from them? Is what they are doing count as major Shirk (associating others with Allah in His Divinity or worship)? Is making allies of them judged the same as making allies of true Kafirs (disbelievers)?
If the state of the people you are living among is as you described: they call upon other than Allah for help, such as the dead, absent or unseen beings, trees, stones, stars, and the like, they are Mushriks (those who associate others with Allah in worship) who are committing major Shirk that take them out of the Din (religion) of Islam. It is not permissible to take them as allies, as is the case with the Kafir. Performing Salah behind them is invalid. It is also not permissible to associate with them or live among them, except for those who call them back to the truth with knowledge, in the hope that they respond to them and become religiously reformed. Otherwise, it becomes obligatory to disassociate oneself from them, and to join another community of people who can be worked with to establish the fundamentals and branches of Islam, and to revive the Sunnah of the Messenger of Allah (peace be upon him). (Part No. 1; Page No. 103) If it is not possible to find a proper community, then one must detach oneself from all communities, even if this causes hardships, based on what was narrated by
Hudhayfah (may Allah be pleased with him) who said:
“The people used to ask the Messenger of Allah (peace be upon him) about the good, but I used to ask him about the evil lest it should afflict me. Once I said, “O Messenger of Allah! We were living in ignorance and evil then Allah bestowed upon us this goodness, so will there be evil after this goodness?” He said, “Yes.” I said, “Will there be goodness after this evil?” He said, “Yes, but it will be tainted (not pure.)” I said, “What will be its taint?” He said, “A people following a way other than my way (Sunnah) and calling to a guidance other than my guidance; you would agree with some of what they do and disagree with some.” I said, “Will there be evil after that goodness?” He said, “Yes, callers at the doors of Hellfire; whoever accepts their invitation to it they will throw him into it.” I said, “O Messenger of Allah! Describe them to us.” He said, “They are from our own people, speaking our language.” I said, “O Messenger of Allah! What do you command me to do if this happens in my time?” He said, “Adhere to the community of Muslims and their leader.” I said, “What if there was not a community for them or a leader? He said, “Then seclude yourself from all these communities, even if you have to bite (i.e. Eat) the root of a tree until death comes to you and you are in that state.”
(Agreed upon by Al-Bukhari and Muslim)
May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.