Mayureshwar is the most important temple in the tour of Ashta Vinayak. The route of Ashta Vinayaka pilgrimage starts from this temple.
The summary of the legend goes like this:
This happened in the Treta yuga. There was a king named Cakrapāṇi who ruled a city named Gaṇḍakī. He was righteous king. He remained childless for many years. He did many pujas, vratas, Yāgas and gave donations to beget a child but remained fruitless. One day sage Śaunaka arrived. He told a way of vrat for pleasing Lord Sūrya. The royal couple followed the procedure. After following the procedure, a child was born with three eyes, a big head and an ugly body. The couple felt happy that they have a child now. They named the child Ugrekṣaṇa, Sindhu and Viprasādan.
The child was very cruel since from his childhood. He fought with other humans and elephants in his childhood. After some years, he wanted to conquer the three worlds and become the ruler of the world. He started a penance to please Lord Sūrya(because he was the reason of his birth). After a severe penance, Lord Sūrya was satisfied with penance and appeared before Sindhu. Sindhu asked for a boon of lack of death. Lord Sūrya granted it by handing him a bowl of nectar. He said
Keep this bowl in your throat. As long as this is in your throat, you will be invicible and no one will be able to kill you. If this is removed or destroyed, your death time arrives.
Due to the power of his boons, he conquered the heaven and imprisoned devatas. He ordered the people to worship him instead of devatas. Donations, sacrifices were stopped in his kingdom. The devatas prayed to Ganesha to remove their problems. He promised that he will incarnate to slay that rakshasa.
Ganesha took birth in the womb of Parvati. This came to know to Sindhu by his spies. He summons his ministers for an advice. They advice to send other asuras to slay that child. But all the asuras fail to accomplish the mission. Finally. the devatas wanted Ganesha to kill Ugrekṣaṇa. Hence, they send Nandi as a messenger of the Gods to release the women belonging to devatas and surrender the svarga nad other lokas to them. But Ugrekṣaṇa doesn't listen to Nandi's advice. Ganesha took oath of slaying Sindhu. Then a fierce battle between Ugrekṣaṇa and Rudra Ganas started.
Ugrekṣaṇa was defeated by Ganesha twice in the battle. Ganesha cut off Ugrekṣaṇa's ears. Embarrassed by the defeat, the rakshas returned to his palace. On the last day of the battle, it was Rudra Ganas who took the advanced step to attack Sindhu. They marched towards the city of the rakshas from all the sides. Ganesha reached there on his vehicle peacock. Then Ganesha did āchamana with sacred water and with his divine axe, he hit Sindhu. By his blow, the bowl with nectar was destroyed. In turn, Sindhu is also dead. The devatas exalted Ganesha for his act.
Lord Ganesha is always referred to as Mayureshwar in the chapters. The place where Ganesha slain the rakshas Ugrekṣaṇa AKA Sindhu AKA Viprasādana became famous as Mayureshwar templeThe locals refer this temple as Moreshwar and village as Moregaon meaning the village of peacocks. This story could be a strong reason for the name. The incarnation is called as Mayureshwar because the lord has ascended to the earth on his vehicle peacock.
This is a summary of Ganesha Purana Sixth Kanda Chapters 1 to 7. (Of these chapters 3,4 describe the slaying of various rakshasas.) The related story in Hindi version can be found here. [Page 8 to 58]. Compete Ganesha Purana in Hindi is available here.
The consorts of Lord Ganesha Siddhi and buddhi are seen along with him in this temple. It is because they are married to him just after the slaying the Sindhu.