The Messenger of Allah ﷺ said, "Do not sit on graves, and do not pray facing them."
قال رسول الله ﷺ: لا تجلسوا على القبور، ولا تصلوا إليها.
Muslim narrated it in the Book of Funerals (972) via Walid bin Muslim, from Ibn Jabir (that is, Abdul-Rahman bin Yazid bin Jabir), from Busr bin Ubaydullah, from Wathila bin Asqa, from Abu Marthad Ghanawi, and he related it.He also narrated it through another route, from Ibn Mubarak, from Abdul-Rahman bin Yazid bin Jabir, inserting "Abu Idris Khawlani" between Busr bin Ubaydullah and Wathila bin Asqa. Bukhari said, "This is a mistake in which Ibn Mubarak erred, adding 'from Abu Idris Khawlani.' It is actually just Busr bin Ubaydullah, from Wathila." More than one narrator transmitted it this way from Abdul-Rahman bin Yazid bin Jabir, without "from Abu Idris" in it, and Busr bin Ubaydullah had indeed heard from Wathila bin Asqa. This is what Tirmidhi (1051) transmitted from Bukhari.I say, Abdullah bin Mubarak was a trustworthy hadith master, so perhaps Abdul-Rahman bin Yazid bin Jabir himself narrated it through two routes. He first heard it from Busr bin Ubaydullah, from Abu Idris Khawlani, from Wathila bin Asqa, then he heard it from Wathila bin Asqa without the intermediary of Abu Idris Khawlani. Abdullah bin Mubarak heard from him through one of these two routes, the one with the intermediary, and narrated it accordingly. Others heard from Abdul-Rahman bin Yazid bin Jabir, from Busr bin Ubaydullah, from Wathila bin Asqa without the intermediary of "Abu Idris Khawlani," among them Walid bin Muslim as recorded by Muslim, and Isa bin Yunus as recorded by Abu Dawud (3229), which contains an explicit statement from Busr bin Ubaydullah that he heard directly from Wathila bin Asqa.As for his saying, "Do not pray facing them," it means do not make them a direction of prayer, because that leads to venerating whoever lies within them, and consequently to worshiping them. Many scholars have explicitly stated that praying facing a grave is forbidden, based on the apparent meaning of the prohibition.As for what is reported from Ibn Abbas, who said that the Messenger of Allah ﷺ said, "Do not pray facing a grave, and do not pray upon a grave," this is a rejected report. Tabarani narrated it in Kabir (11/376) via Abdullah bin Kaysan, from Ikrima, from Ibn Abbas, who related it. This Abdullah bin Kaysan was described by Bukhari as, "His hadith is rejected," Abu Hatim said, "Daif," and Nasai said, "Not strong."Tabarani also narrated it in Kabir (11/411) through another route, from Rushdin bin Kurayb, from his father, from Ibn Abbas, who related it. Bukhari said about Rushdin bin Kurayb, "His hadith is rejected," and Ibn Madini, Abu Dawud, Nasai, and others also declared him daif.As for his saying, "Do not pray upon a grave," he was not corroborated on it.