The Prologue opens with a brief description of two thirteen-year-old boys: William Halloway and James Nightshade. They were born one minute before and one minute after midnight, respectively, and are next-door neighbors. The story begins on a lazy October afternoon. Will and Jim are lying on the front lawn when a lightning-rod salesman comes by and warns them that lightning will strike one of their houses. He points to Jim's house as the victim and leaves a lightning rod behind for him to put up. Will persuades Jim to install the rod, though Jim initially refuses, wanting to see what happens when the storm hits.
The boys jog to the library that evening where they check out books and say hello to Will's father, a 54-year-old man who works as a janitor there. That evening, the boys and Mr. Halloway have separate encounters with handbills for a carnival presented by Mr. Cooger and Mr. Dark. According to the handbill, the carnival will be arriving in town soon.
At three in the morning, Jim and Will are awakened by the sounds of a train and a calliope (sort of like a travelling piano). They follow the train to a meadow where the carnival sets up. The experience is eerie and terrifying; there is definitely something creepy up with this carnival.
In the morning, however, everything appears normal at the carnival except for the Mirror Maze. The boys greet their seventh-grade schoolteacher, Miss Foley, at the carnival and warn her not to go into the Mirror Maze. She goes inside anyway, later emerging terrified of the images staring back at her. She tells the boys she must find her nephew Robert. Will wants to leave, but Jim wants to stay and crack the carnival's mysteries (clearly unaware that curiosity killed the cat). Later that day, Jim goes to the Mirror Maze and is entranced by the images presented to him. Will drags him home. Along the way, they discover a bag belonging to the lightning rod salesman.
Jim wants to investigate the carnival further, so later that night they go back. Jim heads straight for the carousel, only to find that it has an "out of order" sign on it. The boys are caught by a red-haired man named Mr. Cooger, and meet Mr. Dark, the Illustrated Man, for the first time. Mr. Dark tells them that the carnival is closed at the moment, but that Jim can have a free ride on the carousel once it is fixed. Instead of going home afterwards, the boys stay and watch secretly as Mr. Cooger rides the carousel backward with music playing backwards from the calliope. Mr. Cooger grows younger before their eyes until he is a boy of twelve. He runs off into the night, followed by Jim and Will.
The boys stop at Miss Foley's house. Turns out Mr. Cooger is pretending to be Miss Foley's nephew Robert. After saying hello to Miss Foley and fake-meeting "Robert," Jim and Will head home, where they are scolded and sent to bed without supper. Later that evening, Jim slips out of the house and runs over to Miss Foley's for a chat with "Robert." Will follows. The two friends fight. "Robert" comes out of the house and showers them with jewelry. He cries that there's been a burglary. The three boys flee once Miss Foley opens a window and sees them.
The boys make their way back to the carnival, where Mr. Cooger (who still looks like a young boy) hops on to the carousel to try and get himself back to normal. Jim, who wishes he were an adult already, clearly wants to follow, but Will holds him back. While the two of them fight, the carousel spins forward. In their tussle over the control box, the two boys break the mechanism and the carousel spins forward faster and faster. Mr. Cooger tries to escape but cannot. He finally gets off the carousel as a decrepit, centuries-old man. The boys panic and call the police and an ambulance.
In the hullabaloo, Mr. Cooger has disappeared. The two boys then step into the Freak Tent, where the carnival freaks are rehearsing new acts. Mr. Dark invites the policemen and the boys to watch the new act of "Mr. Electrico," who is really the now very old Mr. Cooger. "Mr. Electrico" appears dead, but becomes alive once strapped into an electric chair and shocked with volts of electricity. The policemen think it is a fine show, while the boys and the medical professionals are horrified. The boys return home and go to bed.
Will wakes up an hour later realizing that the lightning rod on Jim's roof has disappeared. He hears an air balloon coming closer and closer. Jim senses it too. The two boys yank up their windows to watch. It is the Dust Witch from the carnival, searching for the boys. She marks Jim's roof with silver slime. (Ew.) After she leaves, the boys wash off the slime and then go back to their bedrooms. Will doesn't feel safe yet, however, so he grabs his archery gear, lures the Witch to a deserted house, and then pierces and destroys her air balloon.
During the night, the carousel starts up again and the calliope plays once more. Miss Foley slips out of her house in the middle of the night. In the morning, Jim and Will head over to the police station. Jim tells Will he dreamed of a funeral for the big air balloon. Will almost tells him what happened the previous night, but they are interrupted by the pitiful sounds of a little girl crying. Will insists that the girl is Miss Foley turned young, though Jim isn't so sure. The boys check her house and indeed find that no one is there. Meanwhile, the carnival forms a parade and marches into town. The boys know this is a ploy to search for the two of them. They try to go back and rescue the little girl, but she is already gone.
Will calls his dad and tells him they have gone into hiding. Camped out under an iron grille, the two boys watch the parade go by. Mr. Halloway spots them. He asks them to leave, but then is accosted by Mr. Dark, who admits his preoccupation with finding Will and Jim. He reveals two tattoos on his palms – one of Jim, one of Will. Mr. Halloway manages to foil the evil intentions of both Mr. Dark and the Dust Witch. He then tells the boys to come to the library at seven that evening so they can work out a plan.
In the library that evening, Mr. Halloway shows the boys old newspaper ads of the same carnival. Turns out, the same carnival has been coming to their town periodically for decades. After a long discussion on the nature of good and evil, Mr. Dark shows up. The boys hide. Mr. Dark finds them and then badly injures Mr. Halloway's hand when he tries to rescue the boys. The Dust Witch enchants the boys so they cannot move under their own power (for Harry Potter fans, this sounds exactly like the Imperious curse). Mr. Dark directs her to kill Mr. Halloway and then leaves with the boys. The Witch fails to kill Mr. Halloway, as he realizes that the secret to breaking her power is to laugh in her face.
Mr. Dark brings the boys and several other accompanying freaks to the carnival; they are being trailed by the Witch and, behind her, Mr. Halloway. Mr. Dark directs the boys into the Wax Museum at the end of the Mirror Maze, and then asks the crowd of carnival attendees to watch the final act of the night – a bullet trick. A volunteer is to fire a rifle at the Dust Witch. Mr. Halloway steps forward to volunteer, then says he requires his son as an assistant. With the help of a jovial crowd, Mr. Halloway manages to call Will forward out of the Wax Museum. Mr. Halloway knows that the bullet he is given for the rifle is made of crayon wax; still, he carves a crescent moon into it and loads it. As he takes aim at the Dust Witch, he tells her that the moon is his smile. He fires and the Witch falls down dead.
Mr. Halloway steps into the Mirror Maze to rescue Jim. He is overcome with shock for a moment by the multitude of elderly, white-haired figures staring back at him. Will steps in and rescues his father. Mr. Halloway ultimately accepts his life (that he will become older and turn into that white-haired man) and begins laughing. The mirrors fall and break.
Mr. Halloway and Will begin searching for Jim in earnest. He is on the carousel. It is moving forward. Mr. Electrico has dissipated into dust. Will reaches for his friend, begging him not to ride the time-altering carousel. The two boys struggle. Will eventually grasps Jim's hand and runs around the outside of the carousel. Jim pulls his friend on. Mr. Halloway finally hits the control switch, and Jim flies off. He appears to be dead.
A little boy comes running over crying for help. Mr. Halloway is fooled for a moment, but then realizes it is Mr. Dark in disguise. He grabs the boy and kills him. The tattoos on Mr. Dark vanish and the freaks are all set free. They run from the carnival. Will begins to cry, but Mr. Halloway stops him. They need to conquer the carnival through laughter and dance. The two begin singing and dancing madly. Eventually, Jim wakes up. He joins them.
Finally tired, the three of them look at the carousel. The boys are tempted for a moment to rush forward into adulthood via the carousel, but then realize succumbing to temptation would result in their becoming proprietors of the carnival. The boys instead decide to have a foot race, in the name of boyhood fun. After some hesitation, Mr. Halloway follows. The three of them reach the finish line at the same instant, and then head back to town.