The Pious Mantra of Lord Ganapati is
Om Gum Ganapathaye Namaha
Mother Parvati made a statue of a child using Haldi (turmeric) and infused life in it. She then empowered the statue with her powers. This created a very powerful and knowledgeable statue-boy. She further instructed the statue-Boy to guard the home.
Shiva was unaware of Mother Parvati’s creation. When he came home, the newly created statue-Boy prohibited Shiva from entering the home. This angered Shiva and after some fights, he cut the head of the statue-Boy.
Parvati heard about the beheading of the statue-boy, that she created. She got struck with grief and demanded Shiva to bring the life back into the child. Shiva then instructed his Rudra Gana (army of his followers) to locate the separated head of the boy. They searched for the head in the entire universe and were unable to find the separated head because Tarakasur hid the separated head. Lord Brahma suggested to Lord Shiva that if a head of anyone who is sleeping with the head towards the North direction can be attached to the body of the child, the child will come back to life.
Shiva instructed his Rudra Gana to get a head as instructed by Lord Brahma. Rudra-Gana cut the head of an Elephant that was sleeping with its head facing North and brought it to Shiva. Shiva attached the head of the Elephant on the child and instilled life in him. Since then the statue-boy is famously known as Gajamuka (face of an Elephant).
Moosakasura was a Rakshas (demon) but he was also a Ganesh devotee. He used to torture all celestial beings. They went to Ganpathi and asked for help. Moosakasura fought with Ganesh. He became very weak and hid himself in a small hole under the mountain. Ganesh broke one of his tooth and used it as a weapon to kill him in the hole. Ganesh, since is also known as Eka-danta (one toothed). Moosakasura, by then, became humble and since he was already a Ganesh devotee became the vehicle of Lord Ganesh.
Ganapathi is the remover of all obstacles, pain and suffering. Therefore Ganesh gained the privilege of being the first to be prayed in any Hindu religious ceremonies.