The followers of Mahadeva, founder of Caitika school of Buddhism, originated the theory of gifts (deyyadhamma), which stated that the merits gained by the donation can be transferred to anyone. Later this theory evolved in the Mahayana theory of 'transfer of merit' (parinamana).
In Mahayana, Bodhisattva is seen as one who transfers his merits to other believers, and takes their bad karma on himself. This is exemplified by Tibetan breathing meditation practice, whereas with every outbreath one imagines that he is sharing merits with others, and imagines that with every inbreath takes in others' demerits.
The 'parinamana' theory infiltrated into the Theravadin rituals , especially in Sri lanka.