عَنْ أَبِي هُرَيْرَةَ رَضِيَ اللَّهُ عَنْهُ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَآلِهِ وَسَلَّمَ: ((مَنْ صَلَّى عَلَى جَنَازَةٍ فَلَمْ يَمْشِ مَعَهَا فَلْيَقُمْ حَتَّى تَغِيبَ عَنْهُ، وَمَنْ مَشَى مَعَهَا فَلَا يَجْلِسْ حَتَّى تُوَضَعَ))
It is narrated from Sayyiduna Abu Hurairah, may Allah be pleased with him, that the Messenger of Allah, peace and blessings be upon him, said: Whoever offers the funeral prayer but does not accompany the deceased for burial should remain standing until the deceased is out of sight. And whoever accompanies the deceased should not sit until the body is placed on the ground.