The all-powerful Monkey King, Sun Wukong, is imprisoned by the Buddha within an ice cage deep in the mountains after rebelling against Heaven.
Five hundred years later, Mountain Trolls attack a group of travelers, killing everyone except for a baby boy named Jiang Liuer, who is adopted by a monk after floating down a river in a basket. Several years later, the same trolls invade a small village and kidnap 49 young children. Liuer saves one of the baby girls and is chased by the trolls for doing so. He stumbles into the cave where the Monkey King was imprisoned and unknowingly releases him from his curse. Sun Wukong defeats the trolls, but he can only use physical attacks, as a remnant of Buddha's seal prevents him from regaining his magical powers, causing him pain whenever he tries to harness his magic.
Wukong attempts to break the Buddha's seal, but to no avail. Liuer and the girl enthusiastically greet Wukong, unaware that he has lost his powers, and pester him with endless questions. When Liuer asks if the god Nezha is a boy or a girl, Sun Wukong replies, "a girl."
> "a girl."
A stone monster, created by the Buddha to keep Wukong imprisoned, attacks the three. Liuer manages to undo the spell on the monster but falls off a cliff in the process. When he awakens, he discovers that Wukong has saved him.
They encounter Pigsy, the Heavenly Immortal "Tian Peng Yuan Shuai" (Marshal of Heavenly Canopy), whom Wukong defeated 500 years ago and who is now reincarnated as a pig demon. Although Wukong is initially hesitant, Pigsy joins the group. They also run into a white dragon that attacks them and tries to eat Liuer, but Sun Wukong scares it off. (This also occurs in the original canon, although, unlike in the original books, the dragon does not turn into a white horse.)
They stay overnight at an inn, but its owners turn out to be trolls in disguise who try to kidnap the baby. More trolls arrive, and Wukong fights them off. The leader of the monsters, Hun Dun, appears, defeating Wukong and capturing the girl. After Wukong refuses to pursue them, Liuer decides to go ahead and save them on his own.
Hun Dun reveals his plan to sacrifice all the children they have kidnapped in order to gain magical powers. Liuer meets with his mentor, Fa Ming, to try to rescue them but nearly gets captured. Wukong finds a doll of himself that Liuer had and realizes how important he is as a figure. He and Pigsy go to help Liuer. After saving Liuer and the 49 children, Wukong defeats the monsters. However, a solar eclipse occurs, and Hun Dun transforms into a giant monstrous beast. Liuer is seemingly crushed by the rubble from Hun Dun's rampage. Upon seeing the boy's apparent death, Sun Wukong is devastated. Full of fury, he forcibly breaks Buddha's seal, regaining his original supernatural powers, and easily defeats Hun Dun.
The final part of this movie connects to the themes in the original canon. Sun Wukong only regains his powers when he fights for someone else rather than for himself, as his powers are meant to protect the monk Xuanzang/Tang Seng/Tang Sanzang against evil and lead him to enlightenment. Sun Wukong as a character is also meant to represent an enlightened mind, which is why his staff emerges from his head. Jiang Liuer himself is the younger Xuanzang, as he only received the name Xuanzang after he was ordained.
In the end, Liuer is shown to have survived Hun Dun's rampage, and they return the abducted children to their families.