The Brahmavaivarta Purana, one of the eighteen Mahapuranas, mentions that Lord Ganesha is an incarnation of Lord Krishna. The legend states that once Goddess Parvati desired to have a son. Thus her husband Lord Shiva advised to perform a vrata for one year, after which she will gain a son. Parvati performed the Punyaka Vrata the guidance of the holy priest Sanat Kumara. After the end of the vrata, Sanat Kumara demanded dakshina (payment) for performing the ritual. Parvati declared that she would give whatever the priest desired. Then Sanat Kumara demanded Lord Shiva as his payment. Sanat Kumara then demanded her husband, Lord Shiva, as the dakshina. The situation became complicated as Parvati could not give away her husband nor could she refuse the priest. She became extremely upset and unconscious. All the gods, including Lord Vishnu and Lord Brahma advised Parvati to honour her word. Thus she gave away her husband. Later the Goddess offered lakh of cows to Sanat Kumara in return of Shiva. But the priest refused her munificent offer.
Goddess Parvati became regretful that even after performing Punyaka Vrata, she could not gain a son and also lost her husband to the priest. Meanwhile all the gods and deities in heaven witnessed an orb of light falling from the sky. Parvati discovered a human figure dressed in yellow garments appearing from the divine orb of light. The divine being announced that He was Lord Krishna. Parvati worshipped Lord Krishna in her grief and wished to have a gorgeous son like Him. Krishna appeared before both Lord Shiva and Parvati and granted them the desired boon.
All the gods persuaded Sanat Kumara to release Shiva from bondage and the Lord returned to His wife Parvati. Later a Brahmana (Brahmin) went to the abode of the divine couple and asked for food. The deprived Brahmana fell at the feet of Parvati and Shiva and praised them. The old person asked for the best of food from Parvati. He declared that the one for whom the Goddess was searching for had arrived. Then immediately he disappeared. The goddess looked all over for him but found a child on the bed in her abode. She picked up the baby in her arms and embraced him. Parvati adopted him as her own son and organized a function. All the gods and goddesses were and invited to admire her son, Lord Ganesha.