Assalaamu alaykum. Suppose that I join the imam during the Maghrib prayer. Then when the imam starts reciting, I notice that he is making a major mistake, even in Surat Al-Faatihah. So I change my intention to pray by myself without following him, and I willingly bow and prostrate at the same time at which he does so in order that other people do not realize that I am praying by myself. Is my prayer valid in that case?
All perfect praise be to Allah, the Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallaahu ʻalayhi wa sallam, is His slave and Messenger.
Whoever prays behind an imam and then sees that the imam makes significant mistakes in reciting the Faatihah that change the meaning of the verses, it is obligatory on him to stop following this imaam. Ar-Ramli wrote, “If the imaam makes mistakes in reciting the Faatihah that change the meaning, it is obligatory to stop following him in prayer, just as is the case if the imaam misses one of the obligatory acts of prayer.” [Nihaayat Al-Muhtaaj]
In this case, if the actions of the person who stopped following the imaam coincide with those of that imam, bowing and prostrating with him, but without intending to follow him, then his prayer is valid. The Hanbali scholar Ar-Ruhaybaani wrote about praying behind a dissolute imam, “If his actions coincide with those of the impious imaam without holding the intention of following him, he is not required to repeat the prayer, because he did not follow a dissolute imaam.”
Allah knows best.
You can search for fatwa through many choices