Answer

Can we pray Ghaib Janaza prayer for a relative who has passed away in a foreign country?

wa ʿalaikum al-salām wa raḥmatullāhi wa barakātuh

It is recommended [ar:mandūb] to perform ṣalat al-janāza on anyone who died outside of your city limits (i.e. al-ghāib). This is the sound opinion in the shafiʿi madhhab, and it is based on the ṣaḥīḥ ḥadīth that the prophet Muhammad (ṣalla-l-lāhu ʿalaihi wa sallam) gathered the companions and performed the janāza prayer for the Abyssinian king after he was informed of the king's death.

The first condition for performing this particular janāza prayer is that the one performing it must be from those for whom the janāza prayer was obligatory shortly before the burial; meaning, they must have been Muslim, adult [ar:bāligh], sane, and pure [ar:ṭāhir] a few mins before the burial. So, if someone became Muslim after said time, or was still a minor, or was not sane, or if the woman was menstruating during said time, then it would not be valid for them to perform this particular janāza prayer.

The second condition is that the one performing this prayer must be certain or have overwhelming doubt that the deceased has been washed. In the event that one is unsure of this and is unable to obtain this information, one must make his intention to pray on the deceased contingent on him being already washed. [1]

Allah knows best.

[1] Haytamī, Tuḥfat al-Muḥtāj (v3 p150-151, Dar Ṣādir)

Answered by Shaykh Omar Mohsin