In the chapter on visiting the grave of the Prophet (peace and blessings be upon him) from his renowned work I'la al-Sunan, Mawlana Zafar 'Uthmani discusses the life of the prophets in their graves:
[It was narrated] from Abu Hurayrah (Allah be pleased with him) that Allah’s Messenger (Allah bless him and grant him peace) said: “No Muslim sends peace upon me except Allah restores my soul to me so that I reply to his salutation.” Abu Dawud narrated it with an authentic (sahih) chain, and Ibn Qudamah mentioned it from the narration of Ahmad with the wording: “None sends peace upon me at my grave...” Al-Bayhaqi opened with this [hadith] the chapter on visiting the grave of the Prophet (Allah bless him and grant him peace). A group of the Imams relied on this [hadith] for support of it [i.e. visiting the grave], from them Imam Ahmad. Al-Subki said: “It is a valid support.” Such was mentioned in Wafa’ al-Wafa’ (2:403).
I say: The meaning of his (Allah bless him and grant him peace) statement, “except Allah restores my soul to me,” the intent of the restoration of his soul – and Allah knows best – is “spiritual attentiveness” and descending to the planes of humanity from absorption in the Transcendent Presence, since his noble soul is busy in the presence of the [Divine] Presence and the Greatest Company away from this world, so when peace is sent upon him, his soul turns to this world to attain the peace-salutation and to reply to the one who sent peace. This was said by al-Subki as mentioned in Wafa’ al-Wafa’ (2:407).
Al-Khafaji said: “That which is apparent in the exegesis of the hadith without affectation is that the prophets and the martyrs are living, and the life of the prophets is stronger, and since the earth is not administered over them they are like sleepers, and the sleeper does not hear and does not speak until he awakens, as Allah (Exalted is He) said: ‘Allah it is who takes away souls at the time of their death, and those which die not in their sleep; then He withholds those on which He has decreed death, and sends back the rest for an appointed term.’ (39:42) Thus, the intent is the “sending back” which is mentioned in the verse, so its meaning is that when he hears the peace-salutation he awakens and replies to it, not that his soul is taken and is then breathed and returned [to him], so there is no [exegetical] dilemma at all.” Such was mentioned in ‘Awn al-Ma‘bud (2:170).
Hence, there is no indication in this of the discontinuity of life as some of them assert. ‘Abd al-Haqq (d. 581 H) narrated in al-Ahkam al-Sughra – and he said “its chain is authentic” – from Ibn ‘Abbas (Allah be pleased with them), he said: Allah’s Messenger (Allah bless him and grant him peace) said: “No one passes by the grave of his believing brother that he knew and he sends peace upon him, except he will recognise him and return his salutation.” Ibn ‘Abd al-Barr also narrated it and authenticated it as transmitted by Ibn Taymiyyah. Ibn Abi al-Dunya narrated from Abu Hurayrah (Allah be pleased with him), he said: “When a man passes by a grave whose [inhabitant] he knew, and he sends peace upon him, he returns his salutation and recognises him; and when he passes by a grave whose [inhabitant] he did not know and he sends peace upon him, he returns his salutation.” The narrations with this meaning are many. Ibn Taymiyyah mentioned in Iqtida’ al-Sirat al-Mustaqim that the martyrs, rather all believers, when a Muslim visits them and sends peace upon them, they recognise him and reply to their salutation. Since this is about the individuals of the believers, what about the master of the messengers (Allah bless him and grant him peace)? A clear mention of his (Allah bless him and grant him peace) hearing the peace-salutation of a visitor is mentioned in a narration narrated by a group from Abu Hurayrah (Allah be pleased with him) with the wording: “Whoever sends blessing on me near my grave, I hear it, and whoever sends blessing on me from afar, it reaches me.” In it is Muhammad ibn Marwan al-Suddi al-Saghir who is weak, and al-Khallal narrated the like of it through the route of al-Buhtari who is very weak from ‘Ubayd Allah ibn ‘Umar from Nafi‘ from Ibn ‘Umar raised [to the Prophet (peace and blessings be upon him)] with the wording: “Whoever sends blessing on me near my grave, I reply to him, and whoever sends blessing on me from another place, they send it to me.” Multiple paths offer strength. Al-Subki said: “What indicates that he (Allah bless him and grant him peace) hears one who sends peace on him near his grave and he replies to him, knowing his presence, is to come. And this is sufficient as a true virtue for the king of the world to spend until he reaches it [i.e. the blessed grave] from the furthest regions of the world.” End quote from Wafa’ al-Wafa’ summarised (2:404).
There is no doubt in his (Allah bless him and grant him peace) life after his departure, and likewise all the remainder of the prophets (upon them blessing and peace) are living in their graves, a life more complete than the life of the martyrs which Allah Almighty gave information of in is Mighty Book, and our Prophet (Allah bless him and grant him peace) is the master of the prophets and master of the martyrs and the deeds of the martyrs are in his scale.
He (Allah bless him and grant him peace) said: “My knowledge after my death is like my knowledge during my life.” Hafiz al-Mundhiri narrated it. Ibn ‘Adi narrated in his Kamil from Thabit from Anas (Allah Almighty be pleased with him), he said: Allah’s Messenger (Allah bless him and grant him peace) said: “The Prophets are living in their graves, praying.” And Abu Ya‘la narrated it with trustworthy narrators, and al-Bayhaqi narrated it and authenticated it.
Ibn Majah narrated with a good chain as said by al-Mundhiri from Abu al-Darda’, he said: Allah’s Messenger (Allah bless him and grant him peace) said: “Increase in sending blessing on me on Friday for it is attended by angels, and no one sends blessing on me except his blessing is shown to me when he finishes with it.” I said: “And after death?” He said: “And after death. Verily, Allah has forbidden the earth from consuming the bodies of prophets, so the prophet of Allah is living and sustained.” This is the wording of Ibn Majah.
It is not contradicted by what Thabit narrated from Anas (Allah be pleased with him) raised [to the Prophet (peace and blessings be upon him)] that “the prophets are not left in their graves after forty nights, but they pray in front of Allah until the trumpet is blown” since Ibn Abi Layla is in its chain and he had a bad memory so the contradiction of what he narrated with the hadiths of trustworthy narrators is unacceptable. Al-Bayhaqi said: “Even if it is authentic with this wording, the intent is – and Allah knows best – they are not left not praying except for this period, and then they begin to pray in front of Allah Almighty.” End quote from Wafa’ al-Wafa’ summarised (2:405,6).
I say: Its outcome according to this is that the prophets are not like other than them from the children of Adam that when they die, their deeds are cut off, rather their deeds continue after death also, and it does not cease but for forty nights. Allah Almighty knows best.
(I‘la al-Sunan, Idarat al-Qur’an wa al-‘Ulum al-Islamiyyah, 10:504-6)