There was a Muslim funeral that included non-Muslims (among the dead) and it was impossible to distinguish between them, as it happened during the floods that struck the south Philippines, as the dead were piled on top of one another. Without a doubt, there were Muslims who died therein, so are they prayed over and how is that accomplished?
All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
It is well-known that it is not permissible to pray the Janaazah (funeral prayer) over a disbeliever, as Allaah The Exalted Says (what means): {And do not pray [the funeral prayer, O Muhammad], over any of them who has died – ever – or stand at his grave. Indeed, they disbelieved in Allaah and His Messenger and died while they were defiantly disobedient.} [Quran 9:84]
If the corpses of Muslims are mixed with those of the disbelievers, and it is impossible to distinguish between them, by seeing who was circumcised or otherwise, then the scholars have different opinions about this issue.
Some of them said: If it is known that the number of Muslims is more, then the prayer is made over them with the intention of praying for the Muslims, but if the number of disbelievers is more, then the prayer is not made. This is the opinion of the Hanafis.
The Shafi‘is, Maalikis and Hanbalis went with the opinion that the prayer is made over all of them but with the intention of only praying over the Muslims, and that they are specified in the Du‘aa’ [supplication], e.g., "O Allaah! Whoever of them was a Muslim, then forgive him and have mercy on him," and so on, and one does not intend to pray over the disbelievers. Ibn Qudaamah said in Al-Mughni:
If there are dead Muslims mixed with dead non-Muslims and it is not possible to distinguish between them, the prayer is made over all of them with the intention of praying over the Muslims. Ahmad said: "The person should place them between himself and the Qiblah [direction of prayer], then he should pray over them." This is the opinion of Maalik and Ash-Shaafi‘i. Abu Haneefah said: "If there are more Muslims, then they are prayed over, but if not then no." This is because consideration is given to the majority, evidenced that Daar Al-Muslimeen [the land of Muslims] is called so because Islam is dominant therein due to the abundance of Muslims therein, and its opposite is Daar Al-Harb [the land of war] because of the abundance of disbelievers therein.
As for the way that the prayer is performed, the Hanbali scholar Al-Buhooti said, “The way to pray over them is to line them up in front of him and pray over them all at once, intending with the prayer the Muslims among them.”
The Shaafi‘i scholar Ibn Hajar Al-Haytami said, “If he wishes, he may pray over them all in one prayer intending with it the Muslims, and this is the better opinion stated in texts, and there is no prayer over the disbeliever here as the intention is decisive. He says in this case, ‘O Allaah, forgive the Muslims among them’; or he prays over them one by one, intending the prayer over him if he were a Muslim.” (abridged)
Allaah Knows best.
You can search for fatwa through many choices