While she was away, Lord Shiva returned and was surprised to find a little boy standing at the entrance to his wife’s chamber. When he tried to enter, the boy blocked his path. “Who are you and why are you blocking my path?” demanded Lord Shiva. “No one enters my mother’s chamber”, declared the boy boldly. Taken aback, Lord Shiva replied, “Step away; I have the right to enter my wife’s chamber.” But the young and courageous boy did not move but stood his ground. Not knowing that this was his own son, Lord Shiva who was quick to anger grew enraged. Not used to be disobeyed he cut off the boy’s head.
Goddess Parvathi on returning from her bath saw her son lying dead and was overcome with grief. She was filled with both anger and sorrow. Seeing this Lord Shiva sent his soldiers to fetch the head of the first beast that they saw. The men rushed and finally came upon an elephant. They immediately took the head to Lord Shiva, who quickly attached it onto the body of the slain boy and gave him life once again.
To further appease his grief-stricken wife he promised that her son would be worshipped first, before all other Gods.
Even today at the entrance of all temples one would find the idol of the elephant-headed God, Lord Ganesha.