
If a person makes a will that someone other than his guardian like an unrelated person or another relative—should lead his funeral prayer, this will is not valid. In Islam, the right to lead the funeral prayer belongs to the guardian of the deceased, and it is best (afzal) for him to do so. However, if the guardian allows an Islamic scholar, imam, or any righteous person to lead the prayer, then it is valid.
Islamic scholars, including Imam al-Nawawi and Imam al-Shafi‘i, state that this will is not reliable because the funeral prayer is the right of the guardian, and such a will cannot remove that right.