Narrated Abu Huraira:
Allah’s Apostle informed about the news of the death of An-Najash (King of Ethiopia) on the day he expired. He said, “Ask Allah’s forgiveness for your brother. ” Narrated Abu Huraira: The Prophet made them align in rows at the Musalla and said four Takbir.
The scholars differed concerning offering the funeral prayer in absentia. Abu Haneefah and Maalik and their followers were of the view that it is not prescribed, and they responded to the story of the Negus and the prayer that was offered for him by noting that this was something that applied only to the Prophet (peace and blessings of Allaah be upon him).
Al-Shaafa’i and Ahmad and their followers are of the view that it is prescribed, and they quote two saheeh hadeeths as evidence. Whether or not a thing applies only to the Prophet (peace and blessings of Allaah be upon him) requires evidence, and there is no evidence in this case. Shaykh al-Islam adopted a middle path and said: If the funeral prayer has not been offered for the absent one, as in the case of the Negus, then it may be offered, but if the funeral prayer has been offered for him, then the communal obligation (fard kafaayah) no longer applies to the Muslims.
The Standing Committee (8/418) was asked: Is it permissible for us to offer the funeral prayer for the deceased in absentia as the Prophet (peace and blessings of Allaah be upon him) did for his beloved the Negus, or did that apply only to him?
It is permissible to offer the funeral prayer in absentia because the Prophet did that, and this does not apply only to him, because his companions (may Allaah be pleased with them) also prayed for the Negus with him, and because the basic principle is that things do not apply only to the Prophet (peace and blessings of Allaah be upon him), but that should be done only for those who made a contribution to Islam, not for everyone. End quote.
Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) was asked: It is proven that the Messenger (peace and blessings of Allaah be upon him) offered the funeral prayer for the Negus in absentia, and the reason for that was that there were no Muslims there who could pray for him. Now the Muslims may die in groups and there is no one to pray for them, as happens nowadays, and there is certainty that no one has offered the funeral prayer for them?
If you are certain that no one has offered the funeral prayer for them, then pray for them, because the funeral prayer is a communal obligation, but probably his family have offered the funeral prayer for him, because the funeral prayer may be offered by one person. Whatever the case, if you are certain that nobody has offered the funeral prayer for him, then you have to offer the prayer for him, because it is a communal obligation which must be discharged. End quote. From Majmoo’ Fataawa al-Shaykh Ibn ‘Uthaymeen (17/149)
[Taken from IslamQA]
More details here.