Praise be to Allah.
The majority of Shaafa’i fuqaha’ are of the view – which is also the view of the Hanbalis – that it is not permissible to bury more than one person in a grave, except in cases of necessity, such as when large numbers have been killed, or there has been an epidemic, a fire or drowning and it is too difficult to bury each person in a separate grave. In that case it is permissible to bury two or three in a single grave. A man should not be buried with a woman except in cases of extreme necessity, and a barrier of earth should be placed between them in that case.
This is indicated by the report narrated by al-Bukhaari (1343) from Jaabir ibn ‘Abd-Allaah (may Allaah be pleased with him) who said: The Prophet (peace and blessings of Allaah be upon him) wrapped two men of those slain at Uhud in a single cloth, then he said: “Which of them had more knowledge of Qur'aan?” When one of them was pointed out to him, he put him in the lahd (niche) first, and he said: “I will be a witness for them on the Day of Resurrection.” And he ordered that they be buried with their blood (wounds) and that they not be washed or the funeral prayer be offered for them.
It was narrated by al-Nasaa’i (2010), al-Tirmidhi (1713) and Abu Dawood (3215) that Hishaam ibn ‘Aamir said: We complained to the Messenger of Allaah (peace and blessings of Allaah be upon him) on the day of Uhud and said: O Messenger of Allaah, it is too hard for us to dig a grave for every man. The Messenger of Allaah (peace and blessings of Allaah be upon him) said: “Dig graves and make them deep, and dig them well, and put two or three men in each grave.”
They said: Who should we put first, O Messenger of Allaah? He said: “Put the one who knew more Qur'aan first.” He (the narrator) said: My father was the third of three in a single grave.
This hadeeth was classed as saheeh by al-Albaani in Saheeh al-Nasaa’i.
Al-Nawawi (may Allaah have mercy on him) said in al-Majmoo’ (5/247): It is not permissible to bury two men or two women in a single grave except in cases of necessity. Similarly, al-Sarkhasi stated that it is not permissible. The view of the majority is that two people should not be buried in one grave, as it says in al-Musannaf. A number of scholars stated that it is mustahabb not to bury two people in one grave, but if there is a case of necessity such as a large number of people who have been killed or who died in an epidemic or as the result of a building collapse or drowning, etc, and it is too hard to bury each one in a separate grave, then it is permissible to bury two or three or more in one grave, as dictated by necessity, because of the hadeeth quoted above. Our companions said: In that case the best of them should be placed closest to the qiblah, and if a man, woman and child are buried together, the man should be placed closest to the qiblah, then the child, then the hermaphrodite, then the woman. Our companions said: The father should be placed before the son, even if the son was better, out of respect to the father, and the mother should be placed before the daughter. It is not permissible to put a man and a woman in the same grave unless there is definitely a case of necessity, and in that case a barrier of dirt should be put to separate them, and there is no difference of scholarly opinion on this point. The man should be put closest to the qiblah even if he is her son.
Some scholars are of the view that more than one person may be buried in a single grave, and that it is only makrooh. This is the view of the Maalikis and was mentioned in one report from Ahmad. It was also the view favoured by Shaykh al-Islam Ibn Taymiyah (may Allaah have mercy on him). See al-Insaaf (2/551); Sharh al-Kharashi (2/134).
Others were of the view that it is not makrooh, but they said that it should be rejected in favour of that which is better.
Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) said: The correct view in my opinion – and Allaah knows best – is the middle view, which is that it is makrooh, as stated by Shaykh al-Islam Ibn Taymiyah. Otherwise, if the first person has been buried and is settled in his grave, then he has more right to it, and in that case a second person should not be introduced to the grave, except in cases of extreme necessity. End quote from al-Sharh al-Mumti’ (5/369).
And Allaah knows best.