Heaven learned that Sun Wukong had caused havoc in the Heavenly Palace, and the Jade Emperor was furious. He ordered Heavenly King Li Jing, the Pagoda-Bearing Heavenly King, to serve as the Grand Marshal for subduing demons, and Nezha, the Third Prince, as the Great God of the Three Altars and the Seas. They mobilized one hundred thousand heavenly troops and generals, set up eighteen layers of heavenly nets and earthly snares, and went to Mount Huaguo to capture the demon monkey. King Li received the order and immediately set off with his troops. The two sides faced off. Sun Wukong showed no fear and used his Ruyi Jingu Bang to fight Nezha for thirty rounds, with neither gaining the upper hand.
All the heavenly troops and generals rushed forward together. Sun Wukong used his power of transformation to make all the monkeys look exactly like him, and the battle became so fierce that heaven and earth turned dark. Neither Prince Nezha nor Muzha could defeat him. Hearing the news, the Bodhisattva Guanyin recommended Erlang Shen to the Jade Emperor, saying that he was the Jade Emperor's nephew and possessed great supernatural powers. The Jade Emperor approved the recommendation and summoned Erlang Shen along with the Meishan brothers to come and help. Erlang Shen and Sun Wukong, one skilled in transformations and the other fast on his somersault cloud, fought from Mount Huaguo to Guanjiangkou and then back again. Erlang Shen turned into a great vulture, Wukong became a sparrow, then turned into a fish, and later into a temple. The two kept changing forms, enjoying the contest immensely.
While Erlang Shen and Sun Wukong were fiercely battling at Mount Huaguo, Taishang Laojun and the Bodhisattva Guanyin watched from outside the Southern Heavenly Gate. Seeing that the two were evenly matched, Laojun quietly took out the Diamond Cudgel and threw it down toward Mount Huaguo, hitting Sun Wukong right on the helmet. Wukong staggered and fell to the ground. Erlang Shen's celestial hound seized the opportunity to pounce forward and bit him firmly on the leg. All the immortals rushed in together, captured Sun Wukong alive, pierced his collarbone with a hook, bound him tightly, and escorted him back to the Heavenly Palace.
When the Jade Emperor saw that Sun Wukong had been captured, he ordered him to be executed at the Demon-Slaying Platform. Neither knives nor axes could harm him, nor could thunder strikes or fires. It turned out that having consumed the Golden Elixir and immortal wine, he had developed an indestructible diamond-like body. Taishang Laojun then petitioned the Jade Emperor to take Wukong back to the Tushita Palace, throw him into the Eight Trigrams Furnace, and refine him with the Samadhi True Fire until he turned to ashes. After forty-nine days, Laojun opened the furnace to check, but unexpectedly, Sun Wukong was not only still alive but had also developed fiery golden eyes, kicked over the Eight Trigrams Furnace, pulled out the Ruyi Jingu Bang, and once again caused havoc in the Heavenly Palace.