The Sunnah indicates that the one who attends the funeral until he offers the prayer will have one qiraat, and whoever attends until the deceased is buried will have two qiraats.
Al-Bukhaari (1325) and Muslim (945) narrated that Abu Hurayrah (may Allaah be pleased with him) said: The Messenger of Allaah (peace and blessings of Allaah be upon him) said: “Whoever attends the funeral until the prayer has been offered will have one qiraat (of reward) and whoever attends until the deceased has been buried will have two qiraats.” It was said, “What are the two qiraats?” He said: “Like two great mountains.”
Muslim (945) narrated from Sa’d ibn Abi Waqqaas (may Allaah be pleased with him) that he was sitting with ‘Abd-Allaah ibn ‘Umar (may Allaah be pleased with him) when Khabbaab came and said: “O ‘Abd-Allaah ibn ‘Umar, have you not heard what Abu Hurayrah is saying? (He says) that he heard the Messenger of Allaah (peace and blessings of Allaah be upon him) say, ‘Whoever goes out with a funeral from the house (of the deceased) until he offers the funeral prayer, then he goes with it until (the deceased) is buried will have two qiraats of reward, each of which is like (Mount) Uhud. And whoever offers the funeral prayer then leaves will have reward like Uhud.’” Ibn ‘Umar sent Khabbaab to ‘Aa’ishah to ask her about what Abu Hurayrah had said, then come back and tell him what she said. Ibn ‘Umar picked up a handful of pebbles from the mosque and turned them over in his hand until his messenger came back and said: “ ‘Aa’ishah said: Abu Hurayrah is speaking the truth.” Ibn ‘Umar threw the pebbles in his hand onto the floor and said: “We have missed out on many qiraats.”
A qiraat is a large amount of reward, which the Prophet (peace and blessings of Allaah be upon him) likened to the mountain of Uhud.
The qiraat which is earned by offering the prayer – can it be attained by offering the prayer only, or must one also go with the funeral procession from the deceased’s house?
Al-Haafiz ibn Hajar said: According to the report of Khabbaab which is narrated by Muslim, “Whoever goes out with a funeral from the house (of the deceased).” Ahmad reported from the hadeeth of Abu Sa’eed al-Khudri: “And walks with it.” This implies that the qiraat is earned only by those who attend from the outset, until the prayer is over. This was stated clearly by al-Muhibb al-Tabari and others. It seems to me that the qiraat may also be earned by those who only offer the funeral prayer, because everything that happens before the prayer is a means that leads to it. But the qiraat of the one who prays only is less than the qiraat of the one who walks with the funeral procession and offers the prayer. The report narrated by Muslim from Abu Hurayrah says, “The least of them is like Uhud,” which indicates that the qiraats may vary.
End quote from Fath al-Baari, 3/234
With regard to one who follows a funeral procession but does not offer the prayer or attend the burial, he is not included in this promise, but there is the hope that he will attain some reward for his intention.
Al-Haafiz ibn Hajar (may Allaah have mercy on him) said: al-Zayn ibn al-Munayyir said: the qiraat is earned only by the one who follows the funeral procession and offers the prayer, or follows the funeral procession and attends the burial, not by one who follows it then leaves without praying. That is because following the funeral procession is a means that leads to one of two things, either the prayer or the burial. If a person takes the means without achieving the ends, then he will not attain the consequences of achieving the ends, although there is the hope that the one who does that will be rewarded according to his intention. End quote from Fath al-Baari, 3/230.
The apparent meaning of the hadeeth is that the qiraat which is earned by attending the burial is only achieved if it is preceded by offering the funeral prayer for the deceased. Al-Bukhaari (47) narrated from Abu Hurayrah (may Allaah be pleased with him) that the Messenger of Allaah (peace and blessings of Allaah be upon him) said: “Whoever attends the funeral of a Muslim out of faith and in the hope of reward, and stays with him until the funeral prayer has been offered for him and the burial is finished, comes back with two qiraats of reward.”
Al-Nawawi (may Allaah have mercy on him) said:
What this implies is that the two qiraats are only attained by the one who stays (with the funeral procession) all the way, until the deceased is buried. If he prays then goes to the grave by himself and attends the burial, he will only earn one qiraat. End quote from Fath al-Baari, 3/234.
Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) said in Sharh Kitaab al-Janaa’iz min Buloogh al-Maraam: One of the things that we learn from the hadeeth (i.e., the hadeeth of Abu Hurayrah quoted at the beginning of this answer) is that the two qiraats are earned only by the one who attends the prayer and the burial, because the Prophet (peace and blessings of Allaah be upon him) said: “Whoever attends [the funeral] until the burial.” It is well known that the prayer comes before the burial.
If a person attends the burial without attending the prayer, such as if a man passes by some people in the graveyard who are burying a deceased person, and he joins them and helps them with the burial, there is nothing in the hadeeth to indicate that a person who attends the burial only will earn the qiraat. Rather he will only earn a qiraat by attending the burial if he also attended the prayer. It is not necessarily the case that a person who earns a reward by doing one thing in conjunction with another will earn it by doing it on its own. End quote.
To conclude, there are five categories of attending funerals:
1 – Attending from the time the deceased is brought out of his house, until the funeral prayer is offered for him and the burial is finished. This is the most complete category, for which there are two huge qiraats of reward.
2 – Attending from the time the deceased is brought out of his house, until the funeral prayer is offered for him. This brings one qiraat of reward.
3 – Offering the funeral prayer for him, even if one did not come with the deceased from the time he was brought out of his house. This brings one qiraat according to the view favoured by al-Haafiz Ibn Hajar, but it is less than the reward of one who attended from time the deceased was brought out of his house, until the funeral prayer is offered for him.
4 – Attending the burial only, without offering the funeral prayer. The apparent meaning of the hadeeth is that there is no qiraat in this case, but a person will be rewarded in accordance with his actions.
5 – Following the funeral procession for a while, then leaving, without attending the prayer or the burial. There is the hope that a person will be rewarded in accordance with his intention in this case.
And Allaah knows best.