The novel opens on an overcast October 23. Two friends, William "Will" Halloway and Jim Nightshade, both on the verge of their fourteenth birthdays, encounter a strange lightning rod salesman who claims that a storm is coming their way. Throughout that same night, Will and Jim meet up with townsfolk who also sense something in the air; the barber says that the air smells of cotton candy. Among the townspeople is Will's 54-year-old father, Charles Halloway (who works in the local library, and who broods philosophically about his position in life, including on how he misses being young like his son). Both Charles Halloway and the boys learn about the carnival that is to start the next day. Will's father sees a sign in a store window that advertises Cooger & Dark's Pandemonium Shadow Show, while Jim and Will find a similar handbill in the street. The boys are excited that a carnival has come so late in the year, but Charles Halloway has a bad feeling about it.
The boys run out to watch the carnival arrive at three in the morning, and they run home after seeing the tents get set up mysteriously. Mr. Halloway talks about this time of night as "soul's midnight," when men are closest to death, locked in the depths of despair. The boys go the next day to explore the carnival and they help their seventh grade teacher, Miss Foley, who is dazed after visiting the Mirror Maze. Later in the day, Jim goes into the maze and Will has to pull him out. Jim insists on coming back that night, and Will agrees, but when they bump into the lightning-rod salesman's bag, they realize that they must stay to learn what has happened to the man. Finally, after searching all of the rides, they go up to a carousel that is supposedly broken. A huge man grabs Will and Jim and tells them that the merry-go-round is broken. Another man tells him to put them down, introduces himself as Mr. Dark and tells them the huge man's name is Mr. Cooger. Mr. Dark is the Illustrated Man, covered in tattoos, and he pays attention only to Jim, who is enthralled by what he sees. Mr. Dark tells them to come back the next day. The boys run off, but then hide and wait. What they see is unbelievable. Mr. Cooger rides backwards on the carousel (while the music plays backwards), and when he steps off he is twelve years old.
They follow Mr. Cooger to Miss Foley's house, where he pretends to be her nephew who got lost earlier at the carnival. Jim tries to meet up with Mr. Cooger, because he wants to ride the carousel, but Will stops him briefly before Jim takes off toward the carnival. When Will reaches the carnival, Mr. Cooger is on the carousel, growing older, and Jim is about to join him. Will knocks the switch on the carousel and it flies out of control, spinning rapidly forward. Mr. Cooger ages over 100 years before the carousel stops, and Jim and Will take off. They return with the police, but Mr. Cooger is nowhere to be found. Inside the tents he is set up as a new act, Mr. Electrico, a man they run electricity through. Mr. Dark tells the boys to come back to the carnival the next day. Will tries to keep his father out of the situation, promising him that he will tell all soon. That night, the Dust Witch comes in her balloon to find Jim and Will, but Will lures her to an abandoned house and destroys her balloon with an bow and arrow. They later both dream of a bizarre funeral for the balloon, featuring a giant, misshapen coffin.
The next day the boys see a young girl crying and realize after talking to her that she is Miss Foley. They go to her house, but when they come back their path is blocked by a parade. The carnival is out searching the streets for them. They hide and the little girl is gone. Will's father sees them hiding under an iron grille in the sidewalk in front of the cigar store and the boys convince him to keep quiet, because the Illustrated Man comes to talk to him. Will's father pretends not to know the two boys whose faces are tattooed on the man's hand, and then when the Witch comes and begins to sense the boys' presence he blows cigar smoke at her, choking her and forcing her to leave. Mr. Dark asks Charles Halloway for his name, and Will's father tells him where he works and who he is. Later that night Will and Jim meet Mr. Halloway at the library, where he has done research and found out some things about the carnival. He tells them that their best weapon is love, but they are not sure how to fight. Then Mr. Dark shows up and the boys hide. He finds them and crushes Charles Halloway's hand when the man tries to fight him. The Dust Witch casts spells on the boys to make them easy to handle and goes to stop Mr. Halloway's heart. Just before he is about to die, Charles Halloway looks at the Witch and begins to laugh hysterically, and his laughter wounds her deeply and drives her away. He goes to the carnival to rescue the boys.
At the carnival Charles Halloway outsmarts Mr. Dark, finds his son, kills the Witch, and destroys the Mirror Maze in a matter of minutes, all through the use of laughter and happiness. Then, he and Will search for Jim. Mr. Cooger turns to dust and blows away before he can be saved at the carousel, and Jim moves towards the merry-go-round. Jim starts to ride and Will tries to stop him. They both end up going for a ride before Will jumps off and rips Jim away from the machine. Jim falls into a stupor, close to death. A child comes begging them to help him, but Mr. Halloway recognizes the boy as Mr. Dark. He holds the boy tight and kills him with affection, because Mr. Dark cannot survive in such close contact with someone good. The carnival falls apart as Will tries to revive Jim. They save Jim by singing and dancing and laughing; their happiness bringing him back from the edge of death.