Do not sit on graves, and do not pray towards them
عن أبي مَرْثَدٍ الغَنَوِيّ رضي الله عنه قال: قال رسول الله صلى الله عليه وسلم: «لَا تَجْلِسُوا عَلَى الْقُبُورِ، وَلَا تُصَلُّوا إِلَيْهَا».
Abu Marthad al-Ghanawi (may Allah be pleased with him) reported: The Messenger of Allah (may Allah's peace and blessings be upon him) said: "Do not sit on graves, and do not pray towards them."
Narrated by MuslimGradeAuthentic
Explanation
The Prophet (may Allah's peace and blessings be upon him) forbade sitting on the graves.
He also forbade praying while facing the graves if the grave lies in the direction of the Qiblah for the praying person because this is one of the means leading to polytheism.
Benefits
It is prohibited to offer prayer in the graveyards, between them, or towards them, with the exception of the funeral prayer, as established by the Sunnah.
Praying towards the graves is prohibited to block the means to polytheism.
Islam prohibited immoderate reverence for the graves or disrespect towards them - neither extremism nor neglect.
The inviolability of a Muslim continues after his death, as indicated by the Prophet's statement: "Breaking the bone of a dead person is like breaking it while he was alive."
Reference
صحيح مسلم (2/ 668) (972).
توضيح الأحكام مِن بلوغ المرام، لعبد الله البسام (2/ 30).
فتح ذي الجلال والإكرام شرح بلوغ المرام، لمحمد العثيمين (1/ 522).
منحة العلام في شرح بلوغ المرام، لعبد الله الفوزان (4/ 285).
Every ḥadīth, grade, explanation and benefit here is shown exactly as HadeethEnc.com publishes it, under its terms for republication. The grade names no grader. The translations and explanations are its authors’ own, and some state rulings; Sabīl’s reviewers have not examined them. The Arabic ḥadīth is the text. Source: HadeethEnc.com