What is the ruling on praying behind a mushrik (one who associates partners with Allah)?
When a person’s shirk is known and clear, it is not permissible to pray behind him.
➊ وَلَوْ أَشرَكُوا لَحَبِطَ عَنْهُمْ مَا كَانُوا يَعْمَلُونَ
“Had even the prophets committed shirk, all the deeds they used to do would have been ruined.”
➋ لَئِنْ أَشْرَكْتَ لَيَحْبَطَنَّ عَمَلُكَ
“If you (that is, Muhammad ﷺ) commit shirk, your deeds will surely be wasted.”
➌ وَبَاطِلٌ مَّا كَانُوا يَعْمَلُونَ
“And whatever they used to do is all void.”
It is learned from these verses that the deeds of a mushrik are not accepted. When his own prayer is void, then inevitably, how can the prayer of those following him be valid?