عَنْ أَبِي مَرْثَدٍ الْغَنَوِيِّ رَضِيَ اللَّهُ عَنْهُ قَالَ: سَمِعْتُ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَآلِهِ وَسَلَّمَ يَقُولُ: ((لَا تُصَلُّوا إِلَى الْقُبُورِ وَلَا تَجْلِسُوا عَلَيْهَا (وَفِي لَفْظٍ) لَا تَجْلِسُوا عَلَى الْقُبُورِ وَلَا تُصَلُّوا عَلَيْهَا))
Sayyiduna Abu Marthad Ghanawi (may Allah be pleased with him) says that I heard the Messenger of Allah (peace and blessings be upon him) say: Do not pray towards graves and do not sit on them. And in another narration, the words are: Do not sit on graves and do not pray on them.