Praying at graves
source: fatāwā jeddah ~ rulings from jeddah ~ tape no. 13
Question #4: “How do we bring together (the Prophet’s) (صلى الله عليه وسلم) prohibition of praying in the graveyard and his praying over the woman who used to sweep in the masjid?”
Shaykh al-Albānī answers:
shaykh al-albaani (rahimahullaah) clarifies the difference between praying towards the graves of the dead and praying over them:
“There is no contradiction between the two narrations, all praises and thanks are to Allāh. The first hadīth (mentioning) the prohibition of praying in the graveyard is as (the Prophet’s) (صلى الله عليه وسلم) saying in Sahīh Muslim: ‘Don’t sit on graves and don’t pray towards them.’  So the prohibition of praying in the graveyard, i.e. praying towards graves, is because it is obligatory for the prayer to be sincerely for the Face of Allāh, the Blessed and Most High, without any glorification for other than Allāh in it at all corrupting or mixing with it, for (that) is one of the types of shirk. So if a Muslim begins to pray for Allāh while facing the grave, there is an obvious suspicion that this person at least intends – as many of the ignorant people do in this era – to seek a blessing from this dead person with his prayer and with his seeking nearness to Allāh, the Mighty and Majestic, by his prayer. Thus, he has fallen into some shirk, he has exceeded the proper bounds in (this affair), and his situation got to the point where it excluded him from the circle of Islām, and Allāh’s protection is sought. This meaning is what should be considered with regard to the prohibition of the Messenger (of Allāh) (صلى الله عليه وسلم) from praying in the graveyard or from praying towards the grave.
As for praying over the dead person while he is in his grave, then this is something else. It has nothing to do with (the previously mentioned contradiction between) praying for Allāh alone, who has no partner, and (praying) towards the grave of a dead person; it is not intended by this (latter) prayer (to ask) for Allāh to forgive him, (to ask) for Him to have mercy on him, as is the implied meaning with regard to supplicating for the dead person.
Therefore, praying over the dead person while he is in his grave is one thing, and praying for Allāh, the Mighty and Majestic, while facing the grave is another thing. (The second situation) is prohibited and (the first situation) is allowed, so there is no confusion between (the two situations).”
~ asaheeha translations ~
 Sahīh Muslim #972
 associating partners with Allāh