«بِالْمَسَاجِدَ» is the regular genitive form when al- is present.

Diptote Causes — Ultimate Broken-Plural Patterns