Yet the issue, in our view, calls for some elaboration, so I say:
Intending to pray in mosques erected over graves invalidates the prayer. The worshipper in such places finds himself in one of two situations:
-
He purposely goes there to pray because of the graves and to seek blessing from them—as many ordinary people do, and not a few of the elite!
-
He happens to pray there incidentally, without any intention related to the grave.
In the first situation there is no doubt that the prayer is forbidden—and, indeed, void. For when the Prophet—may Allah bless him and grant him peace—forbade the construction of mosques on graves and cursed those who did so, then the prohibition of deliberately praying in them is even more obvious; and, as noted a little earlier, such a prohibition entails invalidity.