Answered by Shaykh Yūsuf Badāt
Is it sunnah for the imam of the local masjid to lead the ṣalāt al-janāzah? Would it be considered against the sunnah if an imam of another masjid leads the ṣalāt al-janāzah?
In the Name of God, Most Merciful, Most Compassionate
Jazāk Allāh Khayr/ Thank you for your question
In response to your question, kindly note that in general, any Muslim who is proficient in leading the funeral prayer could do so. The prayer will be valid and the final rites of the deceased would be considered completed.
When someone once passed away, the Prophet (peace and blessings upon him) said,
“Your brother has passed away, proceed to perform his funeral prayer”. (Tirmidhī)
As for who is most rightful to lead the funeral prayer, there is a variance of opinion amongst the great jurists, which is briefly pointed towards the end of this answer. That being said, it should be borne in mind that there is no objection, when the one who has the right to lead the funeral prayer grants permission to another competent person to lead the funeral service. (See: Al-Fiqh ʿAlā Madhāhib Al-Arbaʿah and other known fiqh manuals)
Husayn ibn ʿAlī (may God be pleased with him) states,
“When the funeral is present, the imam (caliph/ muslim ruler) has the most right to lead the funeral, in contrast to others.” (Kanz Al-ʿUmmal)
Abu Ḥāzim (may God be pleased with him) says,
“I was present the day Ḥasan ibn ʿAlī (may God be pleased with him) passed away. I saw Hussayn ibn ʿAlī (may God be pleased with him) saying to Saʿīd ibn Al-ʿĀaṣ (may God be pleased with him) [the ruler of Madīnah], “Move forward! (to lead the funeral prayer), for indeed, had it not been a sunnah, I would not have come forward [to request you].” – (Bazzār, Ṭabrānī & Baiyhaqī)
Through reports such as the ones found in the Mustadrak of Imam Al-Ḥākim, it is well known that Suhaiyb (may God be pleased with him) who was the appointed imam of the local masjid, led the funeral prayer for ʿOmar ibn Al Khaṭṭab (may God be pleased with him) when he was martyred. The likes of ʿOthmān (may God be pleased with him), ʿAlī (may God be pleased with him) and other major Companions were also present in the funeral. After ʿOmar ibn Al Khaṭṭab (may God be pleased with him) demise, the next khalīfah (leader) was not immediately appointed, hence the imam of the local masjid led the funeral service for ʿOmar (may God be pleased with him.) – (See: Mustadrak of Imam Al-Ḥākim)
ʿOmar ibn Al Khaṭṭab (may God be pleased with him) said,
“The father has greater right to lead the funeral prayer of the deceased than the husband.” (Kitāb Al-Āthār of Imam Muḥammad)
The Preferred Opinions According to the Mainstream Schools of Jurisprudence:
The following will be the most rightful to lead the funeral prayer, in order of sequence:
The Ḥanafi School:
The Muslim ruler then the imam of the local mosque, there after the guardian and relatives of the deceased in order of closeness in relationship.
The Shāfiʿi School:
Relatives of the deceased in order of closeness and then the Muslim ruler.
The Māliki School:
The person whom the deceased bequeathed with the condition he is a note worthy pious man, there after the Muslim ruler, and then relatives in order of closeness.
The Ḥanbalī School:
The person who the deceased bequeathed then the ruler and thereafter the relatives of the deceased in order of closeness.
(See: Al-Fiqh ʿAlā Madhāhib Al-Arbaʿah, Fatḥ Al-Bāri, Iʿelā Al-Sunan, Badāiʿi)
And Allāh Knows Best