Each of the Puranas has a different story regarding the birth of Lord Ganesh. In some he is the manasika putra (mind-born son) of Lord Shiva. In others he is the creation of Parvati. In still others he is the son of Shiva and Parvati.
The most popular legend deals with the birth of Lord Ganesh to Parvati. Once while Parvati was going for her bath, she rubbed off the dust and oil from her body and out of it created the figure of a young boy. She infused life into the figure and told him he was her son and should guard the entrance when she went to bath.
Soon after, Shiva came to see Parvati but the young boy blocked his way and would not let him in. Shiva, unaware that this lad was his son, became furious and in great anger fought with the boy whose head got severed from his body in the ensuing battle.
Parvati, returning from her bath, saw her headless son, and in aggrieved anguish threatened to destroy the heavens and earth.
The gods and Shiva pacified her and the latter sent out his ganas, or hordes, to bring the head of the first living being with his head towards the north (the auspicious direction associated with wisdom). The first living creature they found sleeping with his head to the north was an elephant. They brought the head of this animal and Shiva placed it on the trunk of Parvati’s son and breathed life into him.
Parvati was overjoyed and embraced her son, the elephant-headed boy whom Shiva named Ganesh, the lord of his ganas “ Ganpati”