There is no harm in walking in front of or behind the funeral procession
➊ It is narrated from Anas (may Allah be pleased with him) that:
أن رسول الله وأبابكر و عـمـر كـانـوا يمشون أمام الجنازة وخلفها
“The Messenger of Allah ﷺ, Abu Bakr and Umar (may Allah be pleased with them) used to walk (at times) in front of the funeral and (at times) behind it.”
➋ It is narrated from Mughirah ibn Shu’bah (may Allah be pleased with him) that the Prophet ﷺ said:
والماشي يمشى خلفها وأمامها وعن يمينها وعن يسارها قريبا منها
“The one walking on foot may walk behind it, in front of it, on its right and on its left, close to it.”
➌ It is narrated from Ibn Umar (may Allah be pleased with them both) that he saw the Prophet ﷺ, Abu Bakr (may Allah be pleased with him) and Umar (may Allah be pleased with him):
يمشون أمام الجنازة
“walking in front of the funeral.”
◈ There is a difference of opinion on this issue as to whether walking behind the funeral or in front of it is better.
(The majority, Ahmad, Malik, Shafi’i, may Allah have mercy on them) Walking in front of the funeral is better. Abu Bakr (may Allah be pleased with him), Umar (may Allah be pleased with him), Uthman (may Allah be pleased with him), Ibn Umar (may Allah be pleased with them both) and Abu Hurayrah (may Allah be pleased with him) held this view.
(Abu Hanifah, may Allah have mercy on him) Walking behind the funeral is better. Ali (may Allah be pleased with him) holds this position.
(Ibn Hazm, may Allah have mercy on him) The one on foot may walk wherever he wishes, but in our view the preferable way is to walk behind.
(Siddiq Hasan Khan, may Allah have mercy on him) Walking in front and walking behind are equal in merit.
(Shah Waliullah, may Allah have mercy on him) holds the same view.
(Shawkani, may Allah have mercy on him) The rider should go behind the funeral and the one on foot should walk in front.
(Albani, may Allah have mercy on him) Walking behind is better, because the Messenger of Allah ﷺ said:
واتبعوا الجنائز
“Follow the funerals.”