Short answer
In the Hanafi school you are not required to stand when a funeral passes. The Prophet ﷺ stood at first and then stopped, so standing was left. People who are following the funeral should not sit until the body is put down. Standing out of respect is not wrong.
Standing for a passing funeral is not required. The command to stand was followed by the Prophet's ﷺ practice of sitting, so it was left. Those who follow the funeral do not sit before the body is set down.
The four schools agree on this.
Explanation
There are two sets of reports. In one, the Prophet ﷺ told people to stand when they see a funeral, and he stood when one passed, even the funeral of a Jewish man, saying, "Was it not a soul?" In another, Ali reported that the Prophet ﷺ stood, and then he sat down, and so the Companions sat as well.
The Hanafi scholars read the later practice as ending the earlier command. So:
- If a funeral passes you: you do not need to stand. Standing out of respect for the dead is not forbidden, but it is not an obligation.
- If you are following the procession: do not sit before the bier has been put down from people's shoulders, as this is part of the etiquette. See the etiquette of following a janazah.
- At the burial: staying on your feet until the body is placed is the way of good manners; once the burial is done, make dua for the deceased.
Most scholars of the other schools also hold that standing is no longer required, and some say it is still allowed. Do not argue over this at a funeral. Both ways have a basis in the reports, so follow what your community does.
The evidence
Sahih al-Bukhari 1310
Sahih... إذا رأيتم الجنازة فقوموا فمن تبعها فلا يقعد حتى توضع ...
"When you see a funeral, stand; and whoever follows it should not sit until it is put down."
Those who follow a funeral do not sit until it is put down.
Sahih Muslim 962
Sahih... رأينا رسول الله صلى الله عليه وسلم قام فقمنا وقعد فقعدنا ...
"We saw the Messenger of Allah stand, so we stood, and he sat, so we sat."
The Prophet ﷺ stood for a funeral and then sat, so standing was later left.
Sahih al-Bukhari 1312
Sahih... مرت به جنازة فقام فقيل له إنها جنازة يهودي فقال أليست نفسا ...
"A funeral passed by him and he stood. He was told it was the funeral of a Jew, and he said: was it not a soul?"
The Prophet ﷺ stood for a Jewish man's funeral, showing the respect owed to a soul.
Where the ruling is recorded
- al-Hidaya, Kitab al-Salah, Bab al-Jana'iz. The practice of standing for a passing funeral was abrogated; those following do not sit until it is set down.
- Radd al-Muhtar (Ibn Abidin), Kitab al-Salah, Bab al-Jana'iz. Standing for a passing funeral and for the procession.
Reviewed by Hafez Mawlana Abu Darda and Mawlana Akramul Haque Fenwi, Islamic scholars. For a more accurate answer to your own situation, consult a scholar. Quran translation by Saheeh International. Hadith: selections from sunnah.com, Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.