The narrator says, ‘I said to Abu Ja’far (as), ‘The Prayer between the graves?’ He (as) said: ‘Pray in its empty spaces (between the graves) and do not take anything from these as a Qiblah (direction for the Prayer), for Rasool-Allah (sawa) has forbidden from that’.
And he (as) said: ‘And do not take my grave as a Qiblah, nor as a Masjid, for Allah the High has Cursed the one who took graves of their Prophets as Masajids’.
Sanad: Muhammad Bin Musa Bin Al Mutawakkal narrated to us, from Ali Bin Ibrahim, from his father, from Hamaad, from Hareyz, from Zarara who said the above hadith
Source: `ilal al-Sharai’i`, Volume 2, Chapter 75, Hadith #1
Sayed Sistani (hf) says:
It is haraam to perform Sajdah for anyone other than Almighty Allah. Some people place their foreheads on earth before the graves of the holy Imams. If this is done to thank Allah, there is no harm in it, but otherwise it is haraam.