After creating the world, God has three cherubs spread intelligence, wisdom, and foolishness over the world. The third cherub accidentally drops all the foolishness on the village of Chelm, so that everyone in the village is very dumb. A recently orphaned boy named Aaron moves to Chelm to live with his uncle Shlemiel, while Darko, an evil sorcerer, plans to create a golem to destroy Chelm, but needs the Book of Marvels to bring the golem to life. Shlemiel's family is poor so he asks the mayor, Gronam, for a raise. Gronam instead tells him to marry off his three daughters, which will make him rich, while Shlemiel's wife, Sarah, tells Aaron to sell his goat, Zlateh, who cannot make milk. Darko's fox listens in on Shlemiel's plan to marry off his daughters, so Darko poses as a female matchmaker and offers three nonexistent rich husbands to Shlemiel in exchange for the Book of Marvels. When Shlemiel refuses, Darko reveals his true identity and angrily causes a blizzard. While Aaron and Zlateh take shelter from the storm inside a haystack, an imp called the Lantuch is blown inside, hitting Aaron in the head and getting mild amnesia, causing him to forget his spells. When he tries to use a spell to find the biscuits Aaron lost, it instead gives Zlateh the ability to make milk, causing his family to keep her when he returns. Shlemiel informs Gronam that a sorcerer is after the Book of Marvels, and Gronam entrusts the Book to Shlemiel. Darko instructs his fox to spy on Shlemiel and inform him where he hides the Book of Marvels. Shlemiel hides it in the cupboard that Gronam originally took it from, and hides the key in his shoe. When Shlemiel falls asleep on his way to Warsaw to find husbands for his daughters, he points his shoes in the direction of Warsaw to remember which way to go when he wakes up. The fox steals the key from his shoe, and mischievously points the shoes back toward Chelm. After receiving the key, Darko steals the Book of Marvels. Falling for the fox's trick, Shlemiel goes back the way he came, and when he arrives back at Chelm, he thinks that it is a second version of the village. Everyone but Aaron believes this as well. Darko returns to his castle, brings the golem to life, and orders it to destroy Chelm. The golem destroys all the buildings in Chelm except the synagogue because it is sacred, much to the sorcerer's anger. Gronam says that if the golem lives past the Sabbath, it will live forever, and the world will be destroyed. Because the way to kill a golem is written in the Book of Marvels, Aaron goes to Darko's castle with Zlateh and the Lantuch to find the Book. As Aaron reads the information he needs, confirming that what Gronam said was true, the Lantuch accidentally alerts Darko while casting a spell. Darko takes the Book of Marvels back, but Zlateh attacks him, causing the Book to fall into the fire. As Aaron, Zlateh, and the Lantuch escape the castle, Darko sends the golem after them, but the golem has a change of heart due to Aaron's courage and refuses to harm him, even protecting him from Darko's attack. The Lantuch is hit on the head by a rock, regains his memory, and turns Darko to stone. Though reluctant to kill the golem after his latest action, Aaron does so by erasing a symbol on his head to save the world. With Chelm destroyed, all its inhabitants leave to find new homes somewhere else, with Shlemiel and his family intending to go to "Chelm #1".