If the Janaza is brought at the time of Maghrib, will the Fardh of Maghrib be performed
prior to the funeral prayer or after?
It is recommended to perform the Maghrib Salah first, in fact, the Sunna Rak’ats of Maghrib should also be performed. However, if the situation necessitates the funeral prayer being performed prior to the Salah, then it shall be performed first. This is in the case, for example, when the stomach of the deceased has inflated and there is fear that if delayed, it will split open. There must be enough time that even if the funeral prayer is performed first, the Maghrib Salah will not be missed.
And Allah ﷻ knows best.
Imam Ahmad Rida Khan رحمة الله تعالى عليه
Translation by Dr Musharraf Hussain Al-Azhari Translator of Majestic Quran, www.majesticquran.co.uk