Muslims believe that when a person dies, he continues to benefit from the prayers of those still living. This means that a person benefiting from the actions of another person is not contrary to the teachings of Islam.
According to the teaching of Muhammad, it is the duty of all true Muslims to pray for the dead (Durru ‘l-Mukhtar pg 135). See also Mishkat, book 5 chapter 3.
God most certainly exalts the degree of a virtuous servant in Paradise, and the virtuous servant says, “O my Lord, from whence is this exalted degree for me? And God says, “It is on account of your children asking pardon for you.”
A dead person in the grave is like one over his head in water, who calls to somebody to take him by the hand. For he has hope that his father or mother, or his brother, or his friend will pray for him. For when the prayer reaches the dead person, it is more esteemed by him than the whole world, and all that is in it; and verily God most certainly gives to the dead, on account of the prayers of the people of the earth, rewards like mountains, for verily the offerings of the living for the dead are asking forgiveness for them.
(Source: Dictionary of Islam)