Is it permissible to bury the Imam in the masjid when there is a graveyard available in which he can be buried? If this is not permissible, then would the Salah performed in a masjid in which there are graves be valid or not?
It is better to bury the dead in the graveyard. However, if there is a place in the masjid designated for burial where Salah is not performed, then there would be no problem in burying the dead there, and Salah in that masjid would also be valid.
And Allah knows best.