Permissibility of weeping for the deceased and the prohibition on wailing
Question

What is the ruling on weeping for the deceased, if it is accompanied by slapping one’s cheeks and rending one’s garment, especially on the part of some women?
Praise be to Allah.It is permissible to weep for the deceased, so long as it is not accompanied by wailing and slapping the cheeks. The Prophet (blessings and peace of Allah be upon him) wept at the death of the son of his daughter Zaynab (may Allah be pleased with her), as was narrated by al-Bukhari (1284) from Usamah (may Allah be pleased with him), who said: We were with the Prophet (blessings and peace of Allah be upon him) when a message came from one of his daughters, calling him to come to her son, who was dying… The Prophet (blessings and peace of Allah be upon him) got up, and Sa‘d ibn ‘Ubadah and Mu‘adh ibn Jabal, got up and went with him. The child was given to him and his soul was rattling like water poured into a waterskin. His eyes filled with tears and Sa‘d said to him: O Messenger of Allah, what is this? He said: “This is compassion that Allah has instilled in the hearts of His slaves. Allah only shows mercy to the merciful ones among His slaves.”
It was narrated that Abu Hurayrah (may Allah be pleased with him) said: The Prophet (blessings and peace of Allah be upon him) visited the grave of his mother, and he wept and caused those around him to weep too. Then he said: “I asked my Lord for permission to pray for forgiveness for her, but I was not granted permission. And I asked Him for permission to visit her grave and I was given permission. Narrated by Muslim (976).
But if the weeping is accompanied by slapping of the cheeks, rending of the garment, and expressing displeasure with the decree of Allah, then it is not permissible, because of the report narrated by ‘Abdullah ibn Mas‘ud (may Allah be pleased with him), who said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “He is not one of us who slaps his cheeks, rends his garment and cries with the cry of Jahiliyyah.” Narrated by al-Bukhari (1294).
An-Nawawi (may Allah have mercy on him) said: As for lamenting, wailing, slapping one’s cheeks, rending one’s garment, scratching one’s face, tearing out one’s hair, and crying woe, all of that is prohibited according to the consensus of our companions, and the majority of scholars clearly stated that it is haram. … And a number of scholars narrated that there is consensus on that."(Sharh al-Muhadhdhab  5/281).
Ibn ‘Abd al-Barr (may Allah have mercy on him) said: With regard to the Prophet’s words, “When the inevitable happens, no woman should weep”, what is meant by the inevitable is death. Hence what is meant, and Allah knows best, is that no kind of screaming and wailing is permissible after someone dies. As for tears from the eyes and grief in the heart, the Sunnah proves that they are permissible, and this is the view of a number of scholars."(Al-Istidhkar  3/67).
Shaykh Ibn Baz (may Allah have mercy on him) said: What is required of the Muslims in such matters is to be patient and seek reward with Allah, and not to wail, rend their garments or slap their cheeks. Similar to that is the words of the Messenger (blessings and peace of Allah be upon him): “He is not one of us who slaps his cheeks, rends his garment and cries with the cry of Jahiliyyah” and his words in the sahih hadith: “There are four matters of the Jahiliyyah among my ummah that they will not abandon: pride in the good qualities of oneself and one’s ancestors, slandering people’s lineage, seeking rain by the stars, and wailing.” And he said: “If the woman who wails does not repent before she dies, she will be raised on the Day of Resurrection wearing a garment of pitch and a chemise of scabs.” Narrated by Muslim in as-Sahih. Wailing refers to raising the voice in lamenting the deceased. And the Prophet (blessings and peace of Allah be upon him) said: “I disavow the woman who wails, shaves her head and rents her garment.” What is meant by the woman who shaves her head is one who shaves off her hair or pulls it out when a calamity befalls her. The one who rends her garment is the one who does that when calamity befalls her.
The woman who wails is the one who raises her voice when calamity befalls her, All of that comes under the heading of impatience and panic, and it is not permissible for a woman or for a man to do any of these things."(Majmu‘ al-Fatawa  13/414).
And Allah knows best.