According to the majority of scholars, salah (ritual Prayers) cannot be offered in graveyards. The Prophet (peace and blessing be upon him) said, “Do not pray facing a grave and do not sit on one.” However,
du`aa’
(supplication) may be made in graveyards, especially for those who are buried there.

Elaborating more on this, we cite what Sheikh Sayyed Sabiq states in his well-known book, Fiqh Us-Sunnah: `A’ishah reported that the Prophet (peace and blessings be upon him) said, “Allah cursed the Jews and Christians [because] they took the graves of their prophets as mosques” (Al-Bukhari, Muslim, Ahmad, and An-Nasa’i).

Ahmad and Muslim record from Abu Marthad Al-Ghanawi that the Prophet (peace and blessings be upon him) said, “Do not pray facing a grave and do not sit on one.” They also record that Jundub ibn `Abdullah Al-Bajali heard the Prophet (peace and blessings be upon him) say, five days before he died, “The people before you took graves as mosques. I prohibit this to you.”

`A’ishah reported that Umm Salamah mentioned to the Messenger of Allah the churches she saw in Abyssinia and the pictures they contained. The Prophet said to her, “These are the people who, when a pious servant or pious man among them dies, build a mosque [place of worship] upon their graves and put those pictures in it. They are the worst of the whole creation in the sight of Allah” (Al-Bukhari, Muslim, and An-Nasa’i).

The Prophet (peace and blessings be upon him) is also reported to have said, “Allah curses those who visit the graves and take them as mosques and light lamps over them.” Many scholars take this prohibition to be one of dislike, regardless of whether the grave is in front of the imam or behind him. According to the Zhahiri school, this prohibition is one of complete forbiddance and as such, Prayer at a grave site is not valid. According to the Hanbali school, this applies only if there are three graves or more. If there is only one or two graves, then the Prayer is valid although disliked if one prays facing a grave; otherwise it is not disliked.