Narrated Anas bin Malik:
We were (in the funeral procession) of one of the daughters of the Prophet and he was sitting by the side of the grave. I saw his eyes shedding tears. He said, “Is there anyone among you who did not have sexual relations with his wife last night?” Abu Talha replied in the affirmative. And so the Prophet told him to get down in the grave. And so he got down in her grave.
Who is the most entitled of people to lower the deceased into the grave?
Shaykh Muhammad ibn ‘Uthaymeen (may Allaah have mercy on him) said:
The one who is more entitled to do that is the one whom the deceased wanted to do that for him, if he expressed a preference. If he did not express a preference, then it should be the next of kin. If there is one who is knowledgeable then he is more entitled, and if there is no one who is knowledgeable, then he may learn from one who is knowledgeable, and the one who is knowledgeable may direct the one who has no knowledge to carry out this task.
It is not essential for the one who lowers the deceased into the grave to be a mahram of the woman. The Prophet (peace and blessings of Allaah be upon him) commanded Abu Talhah (may Allaah be pleased with him) to go down into the grave of his (the Prophet’s) daughter and bury her in his presence and in the presence of her husband ‘Uthmaan ibn ‘Affaan (may Allaah be pleased with him). (The hadeeth was narrated by al-Bukhaari, 1342).