It is permissible to offer a sacrifice on behalf of the deceased as well as on behalf of the living, such as when a man offers a sacrifice on behalf of himself and the members of his family, intending thereby both those who are alive and those who are dead. This is based on the fact that the Prophet (peace and blessings be upon him) offered the sacrifice on behalf of himself and the members of his family, some of whom had previously died.
Elaborating more on this, the late Sheikh Ibn `Uthaymeen, a prominent Saudi Muslim scholar (may Allah shower mercy on his soul), said:
The basic principle concerning the udhiyah is that it is prescribed for the living, as the Messenger of Allah (peace and blessings be upon him) and his Companions used to offer the sacrifice on behalf of themselves and their families. With regard to what some of the common people think, that the sacrifice may be offered on behalf of the dead, there is no basis for that.
Udhiyah on behalf of the dead may be of three types:
1. When it is offered on their behalf as well as on behalf of the living, such as when a man offers a sacrifice on behalf of himself and the members of his family and intends thereby both those who are alive and those who are dead. This is permissible, and the basis of that is the fact that the Prophet (peace and blessings be upon him) offered the sacrifice on behalf of himself and the members of his family, some of whom had previously died.
2. Offering the sacrifice on behalf of the dead in fulfillment of their last wishes. This is obligatory except in the case of one who is unable to do it. The basis for this is the verse in which Allah says: (Then whoever changes the bequest after hearing it, the sin shall be on those who make the change. Truly, Allah is All-Hearer, All-Knower) (Al-Baqarah 2:181).
3. Offering the sacrifice on behalf of the dead voluntarily and independently of the living—such as offering a separate sacrifice on behalf of one’s father or mother. This is permissible. The Hanbali jurists have stated that the reward for that will reach the deceased and benefit him, by analogy with giving charity on behalf of the dead.
But we do not think that singling out the dead for offering a sacrifice on their behalf is part of the Sunnah, because the Prophet (peace and blessings be upon him) did not offer a sacrifice specifically on behalf of any of his deceased loved ones. He did not offer a sacrifice on behalf of his paternal uncle Hamzah, even though he was one of his dearest relatives; nor on behalf of his children who died during his lifetime, who were three married daughters and three sons who died in infancy; nor on behalf of his wife Khadijah, who was one of his most beloved wives. And it is not narrated that any of his Companions offered a sacrifice on behalf of any of their deceased loved ones.