There was a monster (Rakshasa) called Gajasura. He was all powerful and an ardent devotee of Lord Shiva. He underwent penance for many years to receive special boons from Shiva. Lord Shiva, the god, who is easily pleased by prayers, is deeply moved by Gajasura's devotion. He lesses the monster and offers him a boon. But the devotee is not as innocent as Shiva. He pleads with Shiva to reside in his belly. Left with no option but to grant the boon, Shiva gets into Gajasura's stomach.
Meanwhile on Mount Kailash, Parvati - Shiva's wife, becomes anxious not knowing the whereabouts of her husband for a long time. She searches through the whole universe but to no avail. Finally she approaches Lord Vishnu - the preserver of the world.
Vishnu assures Parvati to find Shiva out. He disguises himself in the form of a street player along with andi - the sacred bull of Shiva and sets out in search of Shanker (another name for Shiva). They go to Gajasura's kingdom and Nandi performs a dance to please the monster. The monster is delighted to see the bull ancing in his honor and wishes to reward the bull. The bull asks for Shiva as a reward. Hearing this, the monster realises that the entertainer is none but Lord Vishnu himself. He also realises that Shiva cannot be made to live in his stomach forever because he has his role to play in the world. He lets Shiva out of his stomach. But he prays to him, that he be made immortal in the memories of people.
To fulfill this wish, Shiva severs Gajasura's head and frees him from the cycle of birth and death. He carries the head along with him. On Mount Kailash, in the Himalayas, Parvati comes to know of Vishnu's victory and is very happy. She makes arrangements to receive her Lord and goes to bedeck herself. She wants somebody to stand guard. So she creates a doll out of the dough that she uses in her bath. She calls him Vinayak - the one who puts off all obstacles. This boy having never seen Shiva, prevents his entry into the palace. In a fit of fury Shiva beheads the boy and enters the palace. Parvati is unaware of the happenings and receives Shiva with warmth, for he had returned after a long period. During the course of their conversation, Shiva mentions the incident at the palace gates and tells her about severing the child's head. Parvati is shocked to hear the news and pleads with Shiva to bring the child back to life for he is like a son to her.
Shiva who has with him the head of Gajasura, immediately puts it on the torso of the dead child. Thus the child comes back to life. That day is Bhadrapad Chaturthi. Shiva blesses him with a boon that the entire world would worship him on that day and also would propitiate him before any auspicious event.
At the same time, all the Gods approach Shiva and request for a leader. Shiva and Parvati have a son called Kumarswami or Kartik. To select the best one of them as a leader of all the Gods, Shiva conducts a test between the two. He says that whoever makes three rounds of the earth sooner than the other, will be made the Ganaadhipati. Kumarswami seated on a peacock, his vahanam (vehicle), starts off for the test.
Vinayak is given a rat which moves swiftly. Vinayak realises that the test is not so easy but he cannot disobey his father. He reverently pays obeisance to his parents and goes around them three times and completes the test before Kumarswami. He says, " my parents pervade the whole universe and going around them, is more than going round the earth." Everybody is pleasantly surprised to hear Vinayak's logic and intelligence. Meanwhile, Kartik is amazed to see Ganesh completing the holy bath at each river that he reached at and ready for another round of the universe.
When he comes back to Kailas, Shiva had already declared Vinayak as the winner. He is blessed as the Supreme God of the universe. After this, Vinayak is called as Ganaadhish, Ganapati and Ganesh. All the gods worship him.