Abu Umama al-Bahili said: Allah's Messenger said: "When one of you dies and you have settled the earth over him, let one of you stand at the head of his grave and then say: O So-and-so, son of So-and-so [name of the mother]! for he will hear him even if he does not reply. Then let him say a second time: O So-and-so, son of So-and-so [name of the mother]! whereupon he will sit up (in his grave). Then let him say: O So-and-so, son of So-and-so [name of the mother]! At this the other one will say: Instruct me, and may Allah grant you mercy! even if you cannot hear it (wa lakin la tasma`un) -- or [in Ibn Hajar's narration]: even if you cannot notice it (wa lakin la tash`urun). Then let him say: Remember the state in which you left this world, which is your witnessing that there is no god except Allah, and that Muhammad is His servant and messenger; that you are pleased with Allah as your Lord, Islam as your religion, Muhammad as your Prophet, and the Qur'an as your book. At that Munkar and Nakir [the angels of the questioning in the grave] hold each other back, saying: Let us go; there is no need for us to tarry here, for he has been instructed his argument. [In Tabarani's and Ibn Qudama's narration:] And Allah will accept his argument without the two of them." A man said: O Messenger of Allah, what if his mother's name is not known?" He replied: "Then let him say: Son of Hawwa' [Eve]."

It is narrated by Ibn Qudama in al-Mughni (1994 ed. 2:319) who mentions that Ibn Shahin narrates it in Kitab dhikr al-mawt with his chain. Ibn Hajar in Talkhis al-habir (2:143) said that Tabarani narrates it with an adequate chain (isnaduhu salih) which, despite its weakness, is consolidated by the witnessing of sound hadiths, and that Dia' al-Din declared it strong (qawwah) in his Ahkam. Shawkani also narrates it in Nayl al-awtar (4:89-90) from the narration of Sa`id in his Sunan from Rashid ibn Sa`d and Damara ibn Habib, and he mentions that `Abd al-`Aziz al-Hanbali also narrated it in his Shafi. Shawkani's citation of Sa`id's narration is not traced back to the Prophet and its wording is: "They used to like (kanu yastahibbun) that it be said to the dead...", "they" referring to the Companions, and Shawkani added that Shafi`i's companions also considered it mustahabb -- desirable.

Among the Hanafis Ibn `Abidin stated in his Hashiyat al-durr al-mukhtar that instructing the deceased after burial is lawful and that it is useful to make him firm and keep him company with a reminder according to what has been mentioned in the reports. Hasanayn Muhammad Makhluf mentioned it in his Fatawa shar`iyya (2:272). See also Ibn `Abidin's Shifa' al-`alil.

Nawawi in al-Adhkar (Ta'if ed. p. 212-213 #494) said:

A very large number of our companions [i.e. of the Shafi`i school] declared that it is desirable -- mustahabb -- to instruct the deceased after burial, and among those who prescribed it are Qadi Husayn in his Ta`liq, his companion Abu Sa`d al-Mutawalli in his book al-Tatimma, the Shaykh, the Imam, the Zahid Abu al-Fath Nasr ibn Ibrahim ibn Nasr al-Maqdisi, Imam Abu al-Qasim al-Rafi`i, and others... The Shaykh and Imam Abu `Amr ibn al-Salah was asked about this instruction to the dead and he said in his Fatawa: "The talqin is what we choose and what we practice."

Ibn Qudama in al-Mughni (1994 ed. 2:319) cites among those who practiced talqin al-amwat or declared it desirable -- mustahabb:

Abu al-Mughira
Abu Bakr ibn Abi Maryam al-Tabi`i
Rashid ibn Sa`d al-Tabi`i
Hamza ibn Jundub al-Tabi`i
Hakim ibn `Umayr al-Tabi`i
The shuyukh of the above-named, i.e. among the Companions
Ibn `Iyash
al-Qadi Abu Ya`la ibn al-Farra'
Abu al-Khattab
Ibn Qayyim al-Jawziyya adds Imam Ahmad to the above list of those who consider it good to instruct the deceased, as stated in the following passage of his Kitab al-ruh (Madani ed. p. 20-21):

Another proof of this [the dead hearing the living] is also the practice of people (`amal al-nas) formerly and to the present time of instructing the dead in his grave (talqin al mayyit fi qabrihi). If the dead did not hear that and did not benefit by it there would be no advantage in it and it would be done in vain. Imam Ahmad was asked about it and he considered it good (istahsanahu) and adduced for it a proof from usage (ihtajja `alayhi bi al-`amal).

There is also related on this subject a weak narration which al-Tabarani related in his Mu`jam from Abu Umama, who said:... [see above]. Although this hadith has not been established (lam yathbut), nevertheless the continuity of its practice in every country and time without objection is sufficient warrant for its performance. For Allah certainly never caused a custom (`ada) to persist so that a people who encompass the eastern and western parts of the earth, and who are the most perfect of peoples in intelligence, and the most comprehensive of them in sciences, should agree to address one who neither hears nor reasons, and approve of that, without some mistrustful one of that people disapproving it! But, the first established it for the last (sannahu al-awwalu li al-akhir), and the last imitates the first therein (wa yaqtadi fihi al-akhiru bi al-awwal). And were it not that the one who is addressed hears, this act would have the status of address to earth and wood and stone and the non-existent -- and this, even if one person might approve of it, the learned would unanimously abhor it and condemn it.

Abu Dawud related in his Sunan with a chain to which there is no objection: The Prophet attended the funeral of a man, and when he was buried he said: "Ask confirmation for your brother, for he is now being questioned." So he gave information that he was being questioned at that time. And since he was being asked, then he could hear the dictation. And it is valid on the Prophet's authority that the dead one hears the beating of their sandals when they turn to leave.

`Abd al-Haqq [Ibn al-Kharrat al-Ishbili] related on the authorities of one of the saints that he said: "A brother of mine died and I saw him in my sleep. I said: O brother, what was your state when you were placed in your grave? He said: Someone kept coming to me with a bright flame of fire. If it had not been that someone made du`a for me I would have perished."

Shabib ibn Shayba said: "My mother enjoined me at her death saying: O my son, when you bury me, stand at my grave and say: O mother of Shabib, repeat: la ilaha illallah. So when I buried her, I stood at her grave and said: O mother of Shabib, repeat: la ilaha illallah. Then I departed. When night came I saw her in my sleep and she said: O my son, I was on the point of perishing but for the expression: la ilaha illallah overtaking me. So you have observed my last wish, O my son.

Shaykh Nuh `Ali Salman said as reported in The Reliance of the Traveller (p. 921-924 w32.1-32.2):

Instructing the deceased (talqin) is when a Muslim sits besides the grave of his fellow Muslim after burial to speak to him, reminding him of the Testification of Faith "There is no god but Allah, Muhammad is the Messenger of Allah," and certain other matters of belief, such as that death is real, paradise is real, hell is real, and that Allah shall raise up those who are in their graves -- and praying that the deceased will prove steadfast when the two angels question him. It does not have a particular form, but rather anything that accomplishes the above is called "instructing the deceased." The following evidence may be adduced for its validity in Sacred Law:

The rigorously authenticated (sahih) hadith that the Prophet (Allah bless him and give him peace) ordered that the bodies of the idolators slain on the day of Badr be thrown into a well whose interior was uncased with stones, then he approached the well and began calling the unbelievers by their names and fathers' names, saying: "O So-and-so son of So-and-so, and So-and-so son of So-and-so: it would have been easier if you had obeyed Allah and His Messenger. We have found what our Lord promised to be true; have you found what your Lord promised to be true?" To which `Umar said: "O Messenger of Allah, why speak to lifeless bodies?" And he replied: "By Him in whose hand is the soul of Muhammad, you do not hear my words better than they do."
The Prophet (Allah bless him and give him peace) said:
"When a servant is laid in his grave and his friends have turned away from him and he hears the footfalls of their sandals, two angels come to him, sit him upright, and ask him: "What were you wont to say [i.e. what did you use to say] of this man Muhammad (Allah bless him and give him peace)?" The believer will answer: "I testify that he is the slave of Allah and his Messenger," and it will be said: "Look at your place in hell, Allah has changed it for a place in paradise," and the man will behold both of them..."

`Uthman ibn `Affan (Allah be well pleased with him) relates that when the Prophet (Allah bless him and give him peace) used to finish burying someone, he would stand by the grave and say, "All of you, ask Allah to forgive your brother and make him steadfast, for he is now being asked."
Abu Umama said: "When I die, do with me as the Prophet (Allah bless him and give him peace) ordered us, saying: "When one of your brothers die and you have smoothed over the earth upon his grave, let one of you stand at the head of the grave and say: "O So-and-so son of So-and-so [note: the latter "So-and-so" is feminine, naming the deceased's mother] -- for he will hear, though he cannot reply -- and then say: "O So-and-so son of So-and-so," and he will sit upright; and then say: "O So-and-so son of So-and-so," and he will say: "Direct me, Allah have mercy on you," though you will not hear it, but should say: "Remember the creed upon which you departed from this world, the testification that there is no god but Allah, and Muhammad is His slave and Messenger, and that you accepted Allah as your Lord, Islam as your religion, Muhammad as your Prophet, and the Koran as your examplar." For then the two angels Munkar and Nakir will take each other's hand and say: "Let us go, what is there to keep us beside someone who has been instructed how to make his plea?" A man said: "O Messenger of Allah, what if one does not know the name of his mother?" and he answered, "Then he should mention his descent from his mother Eve, saying: "O So-and-so son of Eve...."
Tabarani related this hadith in his al-Mu`jam al-kabir, and Ibn Hajar `Asqalani has said that "its chain of transmission is sound" (isnaduhu salih) in Talhis al-habir fi takhrij ahadith al-Rafi`i al-kabir (2:143). Some scholars have said that this hadith is not well authenticated (da`if), while others have gone to the extreme of calling it a forgery.

The first three of the above hadiths, all of them rigorously authenticated (sahih), show that:

a dead person hears the words of a living person speaking to him and even the sounds and movements around him;
the dead are questioned in their graves;
and that it is legally valid after burial for a living person to ask Allah to forgive the deceased and make him steadfast for the questioning of the two angels.
As for the fourth hadith, scholars have felt comfortable with it (ista'nasa bihi al-`ulama'), saying that if the deceased can hear, we should let him hear these words which he is in the direst need of in such circumstances, and even if the hadith that has conveyed them is not well authenticated, its content is valid and true (madmunuhu kalamun haqqun sahih).

The foregoing is what has been said about instructing the deceased (talqin), so whoever does it cannot be blamed, since they have something of a case for it; and whoever does not cannot be blamed, because they do not consider the case sufficient. In any event, we should be anxious to promote love and brotherhood between Muslims, and not divide the ranks with questions like this, for the important thing is our belief in the oneness of Allah, and the unity of the Islamic Community.