Jami` at-Tirmidhi Book 10, Hadith 78
The Messenger of Allah said: "Whenever you see a funeral (procession), stand up until it goes ahead of you or it is put down."
"I accompanied Abu Hurairah for ten years, and I heard him saying: 'I heard the Messenger of Allah saying: "Whoever follows a funeral, and carries it three times, then he has fulfilled the right that is required from him."
The Messenger of Allah said: "Whenever you see a funeral (procession), stand up (for it). Whoever follows it, then do not sit down until it is put down."