In The Name of Allaah, The Most Merciful The Bestower of Mercy
Tawaaf [Circumambulation] around a grave, stroking them [with one’s hands] and seeking blessings from them are acts of shirk. Circumambulation is an act of worship and it has not been legislated in any [other place] besides the Ka’bah and likewise walking between Safaa and Marwa is [only legislated at Safaa and Marwa].
Stroking [graves], seeking blessings from them and hoping to be benefited –in this life and the next- by way of such acts is [tantamount to] deification. It is similar to what the pre-Islamic idolaters used to do with their gods. Whoever hopes [for reward, blessings etc] through [these acts of worship at the] graves, then indeed he has exalted that which Allaah has not legislated to be exalted. The proof to show that these practices are acts of Shirk is the hadeeth of Abee Waaqid Al-Laythee [radiyallaahu-anhu] who said:
‘’We went out with the Messenger of Allaah [sallal-laahu-alayhi-wasallam] to the [military] campaign to Hunayn, while we were new converts from disbelief to [Islaam]. The idol worshippers had a lote- tree in [whose vicinity] they used to stay and hang their weapons, and it [i.e. this lote-tree] was called Dhaat Anwaat. So when we went pass a tree, we said: “O Messenger of Allaah set up a Dhat Anwat for us just as they have a Dhaat Anwaat.’’ So the Messenger of Allaah [sallal-laahu-alahi-wasallam] said: ‘’Allaah is the Greatest! This is a path that has proceeded (from the people of the past). By Allaah in whose Hand my soul is, you have stated just as the children of Israa-eel stated to Moosaa (alayhis-salaam): “O Musa (Moses)! Make for us an ilahan (a god) as they have aaliha (gods).” He (Moosaa) said: “Verily, you are a people who know not (the Majesty and Greatness of Allah and what is obligatory upon you, i.e. to worship none but Allah Alone, the One and the Only God of all that exists).” Reported by Ahmad and Tirmidhee and it is a sound hadeeth.]
Those [new Muslims] wanted to perform that act of worship is that particular place and (also) to seek blessings; so the Messenger of Allaah [sallal-laahu-alayhi-wasallam] referred to what they sought after as worship of another deity besides Allaah. That [act they sought after] is a means to Shirk, but after the Messenger of Allaah [sallal-laahu-alayhi-wasallam] clarified the affair for them, they turned in repentance and obedience to [Allaah and His Messenger]. Seeking blessings from graves, circumambulation round them and stroking them are more severe [acts of shirk and sin] than what those [new Muslims] sought after.
[Source: An Excerpt from ‘Al-Min’dhaar Fee Bayaani Katheer Minal Akhtaa Ash-Shaa’i’ah page: 11’. slightly paraphrased]