Chapter 16 of 20 · Rudra Samhita - Kumara Khanda · Overall chapter 166 of 464
Severing of Ganesha's Head
Shiva and Vishnu together finally overcome Ganesha only once Parvati's protective Shaktis withdraw their support - and even then, Vishnu resorts to deliberate deception to distract the boy rather than defeating him outright, allowing Shiva to sever his head with the trident while his back is turned.
Brahma said
Mahesha favours his devotees. Narada, hearing what you said, he wished to fight the child. He called Vishnu and consulted him. With a great army and the immortals the three-eyed divinity faced him. Remembering Shiva's lotus feet, the gods fought alongside him, filled with great strength and eagerness because Shiva had cast a favourable glance on them. Hari, extremely brave and valiant, fought with him; the brave and devoted one was Shiva's form and fought with great divine weapons. With his staff Ganadhipa struck the bulls among the immortals. The Shaktis had given the valiant one great strength and he fought Hari fiercely. Sage, by his strength all the immortals and ganas were embarrassed. Struck by his staff, Vishnu withdrew from the battle. Sage, Shiva with his soldiers fought him a long time, and seeing how terrible he was, was filled with wonder. "He has to be killed by deceit; there is no other way." Resolving so, he stayed in the midst of the soldiers. The divinity Shiva is without qualities but had taken a form with them. Seeing it, Vishnu and the other gods returned to the battle, and so did Mahesha's ganas, full of delight. All of them gathered gladly with great enthusiasm. Shakti's brave son walked the path of heroes. First he honoured Vishnu, who bestows every happiness, with his staff. "Lord, I will delude him, and then you can kill him. He is full of tamas and cannot be assailed; he cannot be killed any other way." Vishnu is skilled at creating delusion. Having so resolved, he consulted Shambhu, and with Shiva's leave acted so. Sage, seeing Hari in such a state, the two Shaktis gave their strength to Ganesha and vanished. When the two Shaktis vanished, Ganesha grew stronger. He hurled his club at Vishnu, who stood there. Vishnu remembered Shiva Mahesha, his lord, kind to devotees, and somehow managed to dodge the weapon's course. Shankara saw the lone one's face and came there, enraged and eager to fight, seizing his trident.
Shivaa's brave, very strong son saw Shambhu Maheshvara advancing with the trident to kill him. Remembering his mother's lotus feet, he struck him on the hand with a spear. The strength of immensely valiant Ganesha had grown because of Shivaa and the two Shaktis. The trident fell from the hand of Shiva the paramatman. Seeing it, the giver of prosperity took up his Pinaka bow, but Ganeshvara knocked it to the ground with his club. Five of his hands were struck and he seized the trident with five others. "I have indeed suffered a great misery now. What will become of the ganas?" So he said, following the world's ways.
Meanwhile with the club brave Ganeshvara struck the gods and ganas. Strong because of what the Shaktis had given, he made the gods and ganas flee in the ten directions. No one in the battle could stand against his blows. Looking at Ganesha, Vishnu said: "He is blessed, immensely strong and valiant, brave and fond of fighting. I have seen many gods and many danavas, daityas, yakshas, gandharvas and rakshasas, and none equals this leader of ganas. He has all the energy, beauty, prowess and qualities of the three worlds." While Vishnu spoke, Shakti's son Ganeshvara whirled the club and hurled it at him. Remembering Shiva's lotus feet, Hari took his chakra, and the chakra quickly shattered the club into pieces. Ganesha hurled the broken club at Hari, but Garuda seized it and made it fail. So for a long time immensely valiant Vishnu and Ganesha fought each other. Shakti's supremely brave son remembered Shiva. The powerful one again picked up his unmatched staff and struck Vishnu with it, and unable to bear the blow, Vishnu fell to the ground, but he got up quickly and fought Shivaa's son again. At this time the trident-wielder came there and with his trident cut off his head. So, Narada, the head of the leader of the ganas was severed. The army of ganas and the army of gods stood motionless. Narada, you went to Devi and told her all: "Proud one, listen. Do not cast your pride aside now." Narada, you love to create dissension. Saying this, you vanished from the spot. Though you are not subject to deviation, you are a sage who always follows what is in Shambhu's mind.
Retold in our own words from Bibek Debroy's English translation of the Shiva Purana (Penguin Classics). Names, numbers and the order of events follow the source.