The greeting of salam at the grave and its reply is general
The noble Companions (may Allah be pleased with them) knew well that the salam recommended at the blessed grave is the same salam that is said at an ordinary meeting, and which is recommended for every Muslim to say when meeting his brother or when visiting his grave. In this salam the Prophet ﷺ and the ordinary believers are equally included. The Prophet ﷺ said:
ما من رجل يسلم على إلا رد الله على روحي حتى أرد عليه السلام
“If anyone sends salam upon me, Allah the Exalted will return the soul to my body, until I reply to his salam.”
And it is narrated concerning the ordinary believers:
ما من رجل يمر بقبر أخيه المؤمن كان يعرفه فيسلم عليه إلا عرفه ورد عليه السلام
“When a person passes by the grave of his believing brother whom he used to know, and greets him with salam, he recognises him and replies to his salam.”
The sunnah supplication for visiting graves
It was the habit of the Prophet ﷺ that when he went to the graveyard, he would recite this supplication:
السَّلَامُ عَلَيْكُمْ أَهْلَ الدِّيَارِ مِنَ الْمُؤْمِنِينَ وَالْمُسْلِمِينَ وَإِنَّا إِنْ شَاءَ اللَّهُ بِكُمْ لَاحِقُونَ أَنْتُمْ لَنَا فَرَطٌ وَنَحْنُ لَكُمْ تَبَعٌ أَسْأَلُ اللَّهَ الْعَافِيَةَ لَنَا وَلَكُمْ
“Peace be upon you, O people of the abodes, among the believers and the Muslims. If Allah the Exalted wills, we will be joining you. You went ahead of us, and we are following you. I ask Allah the Exalted for well-being for us and for you.”
Salawat and salam in the prayer is better than salawat and salam at the grave
He used to teach the noble Companions (may Allah be pleased with them) this same supplication. Sending blessings and salam upon him during the prayer is better than saying it near the blessed grave. Every Muslim is commanded to do so, and it is also a distinction of his. Whoever sends blessings and salam upon him, Allah the Exalted sends mercy upon that person. Whoever sends blessings upon the noble Messenger once, Allah sends mercy upon him ten times, and whoever says salam once, Allah sends mercy upon him ten times. Therefore, this aim is achieved for the Prophet ﷺ and for the member of the Ummah when he sends blessings and salam upon the Prophet ﷺ while entering the Prophet’s Mosque or any other mosque. Hence, going to the blessed grave brings no special benefit either to him or to the one who says the salam. The Quba Mosque, however, is an exception to this, because the noble Companions (may Allah be pleased with them) used to go there every Saturday and demonstrate following the sunnah. They knew that by presenting themselves at the Quba Mosque they were fulfilling the duty of following the Messenger, and that by sending blessings and salam in the Friday prayer and within the prayer in the Prophet’s Mosque they gathered both rewards, because praying in the Quba Mosque brings both benefits at the same time.
The same is the case with a person who goes to visit the graves of the people of Baqi’ and the martyrs of Uhud, just as the Mercy to the two worlds used to go there and supplicate for them. In this there is benefit and only benefit, and no harm. Supplication for the people of Jannat al-Baqi’ and the martyrs of Uhud is not made within the prayer, and for this reason going to their graves is a separate matter. Despite all this, it is reported from Imam Malik (may Allah have mercy on him) that it is disliked to make it a sunnah. In this regard, the practice of Ibn ‘Umar (may Allah be pleased with them both) is not obligatory to follow. Just as his touching the part of the Prophet’s minbar where the Messenger of Allah used to sit was not considered something to act upon.
Ibn ‘Umar (may Allah be pleased with them both) considered it recommended to go to the places where the honoured Messenger had prayed; indeed, going there and praying became his habit. Despite this, the majority of the noble Companions (may Allah be pleased with them) did not regard it as recommended. The majority of the noble Companions (may Allah be pleased with them) held dear every act that the Messenger of Allah approved, and that is that wherever the time of prayer arrives, one must pray right there.