One of the famous stories associated with Lord Ganesha and Lord Kartikeya is their competition between them for the leadership over the Ganas and obstacles. This story is also a part of the Vinayaka Chaviti vratam.
For reference, I'm quoting an excerpt from this website:
Once all the gods, sages meet Shiva and pray him and ask him to appoint someone as a head to the Vighnas. Kumaraswamy comes forward and asks his father to give the head of vighnas post to him as Gajanana is short and fat. But Gajanana(Ganesha) also wants the post. So Shiva puts them to a test. The test is to go around all the worlds and to bath in all the holy rivers present in those worlds and return. Whoever comes first will be appointed as the head of Vighnas.
Listening to which Kumaraswamy sits on his vehicle Peacock and flies for completing the test. Ganesh on the other hand feels sorrow approaches his father and prays him saying, “you know that iam fat, short and cannot move as fast as Kumaraswamy. So I request you to advice me on how to win this competition.”
Lord Shiva responds to his prayer and says that if you recite the NARAYANA MANTRAM and do pradakishna to parents( circling around the parents) it is equal to bathing in all the holy rivers. Shiva teaches Ganesha Narayana mantra and Ganesh reciting the mantra does the pradakshina to his parents. Because of the affect of the mantra and pradakishna, Kumaraswamy always sees his brother Ganesh to finish the bath and leave as he tries to enter for a bath in any of the holy river.
Kumaraswamy returns to kailasam and tells his father to forgive him of his ignorance in recognizing his elder brothers capability and requests him to place Ganesha as the Head of Vighnas.
So Ganesh is named as the head of the Vighnas and hence called VIGHNESHWAR( LORD OF VIGHNAS). This ceremony of placing Ganesha as the head of the Vighnas was done on Bhadrapadha sudha chaviti and from that day on it is celebrated as Vinayaka chaturthi or Ganesh chaturthi or Vinayaka chaviti.
Which Puranas contain this story of competition between Ganesha and Kartikeya for the leadership over the obstacles (Vighnadhipatyam) ?