SHAFAQNA – The Grand Ayatollah Makarem Shirazi answered questions about building a Mosque in a place where it used to be a cemetery.
Question: Can a Mosque be built in a place where it used to be a cemetery? What is the ruling if there are graves of scholars in there? Is it allowed to perform Salaat there?
The Grand Ayatollah Makarem: The only way a cemetery can be changed into a Mosque that currently no burials are allowed there; and building a Mosque will not lead to destruction of graves especially the graves of the scholars; but any way, performing Salaat in that Mosque is allowed.
Source: PERSIAN SHAFAQNA