The story is set around 1896 in Adenville, a small town of 2,500 people in southwestern Utah. The narrator, seven-year-old John Dennis Fitzgerald, known as J.D., recounts the exploits of his 10-year-old brother Tom Dennis, or T.D., whom everyone calls "The Great Brain" for his cunning intelligence and relentless schemes. Their oldest brother, Sweyn, is nearly 12. The Fitzgerald family is among the roughly 500 non-Mormon residents in a predominantly Mormon town. Papa edits and publishes the local newspaper, the
Adenville Weekly Advocate, and Mamma runs the household with the help of Aunt Bertha, not actually a relative but a family friend who has lived with them since her husband's death.
Papa orders the first indoor water closet, or flush toilet, ever seen in Adenville from Sears Roebuck. While the town's only plumber digs a cesspool in the backyard, Tom charges neighborhood children a penny apiece to watch from the back porch, hiring J.D. as a recruiter on commission. When the toilet arrives, the stationmaster unpacks it in the middle of Main Street before a crowd of about 200, humiliating Papa. After Papa assembles the water closet and demonstrates it for adults only, Tom sets up J.D. as a barker with a cowbell the next morning, advertising "the magic water closet that doesn't stink" for a penny admission. Mamma returns home, shuts down the operation, and forces Tom to refund every penny. When 20 extra children fraudulently join the refund line, Tom loses an additional 20 cents from his own savings, marking the first time his great brain has cost him money.
Mamma has a strict system for childhood diseases: When one brother falls ill, she puts the other two in bed with him so they all get infected at once. Sweyn always catches diseases first and recovers while the younger boys still suffer, then torments them by boasting about the food he eats and the games he plays. Determined to catch a disease first for once, J.D. sneaks into a quarantined friend's house on two separate Saturdays to contract the mumps. After more than two weeks, he develops swollen jaws and celebrates so openly that Papa thinks he is delirious. Mamma puts Tom and Sweyn in bed with J.D. to catch the disease, but they retaliate by eating drumsticks, cake, and candy in front of J.D. while he can only swallow mush and soup. When J.D. finally recovers and tries to gloat, Tom and Sweyn impose "the silent treatment," refusing to speak to or acknowledge him. After three miserable days, Tom offers a deal: J.D. can end the silence by surrendering his prized Indian beaded belt, a birthday gift from Uncle Mark, the town marshal. Desperate for his brothers' company, J.D. agrees.
That summer, the boys encounter neighborhood friends Frank and Allan Jensen heading out to explore Skeleton Cave, a vast cavern near town. That evening, the Jensen brothers do not come home. Uncle Mark organizes search parties, but after two days the situation seems hopeless: An underground river may have carried the boys to their deaths. Tom eavesdrops on Uncle Mark's grim report to Papa, then retreats to his loft to think. Hearing his purebred Alaskan dog, Brownie, bark outside the barn, Tom has an idea. He remembers that the Jensens' sheep dog, Lady, is in heat, meaning Brownie can track her scent. Tom has Brownie smell Lady's doghouse, then rubs beef liver on their shoes to create a scent trail for the return journey. Papa reluctantly lets Tom enter the cave with Uncle Mark. After more than four hours of anxious waiting, Brownie's bark echoes from the passageway, and all emerge safely. The town hails Tom as a hero, while J.D. feels overlooked despite his dog making the rescue possible.
Papa persuades Abie Glassman, an elderly Jewish peddler who travels southwestern Utah with his wagon, to settle in Adenville and open a variety store. Abie worries the business will fail because Mormons are expected to shop at the Z.C.M.I. (Zion's Cooperative Mercantile Institution) store, but Papa arranges a rental with the local banker. A rumor that Abie's strongbox is full of gold discourages concern about his welfare. Abie faints three times over several weeks but refuses to see the doctor. After his store stays closed for days, Papa and Uncle Mark break in and find Abie barely alive. Dr. LeRoy diagnoses him as dying of starvation. Mamma takes Abie home and tries to feed him broth, but he cannot swallow. He dies in her arms. The entire town attends the funeral. Papa delivers a pointed analysis: The butcher and grocer both noticed Abie had stopped buying food but did not worry because he was Jewish, an indifference Papa argues would never have occurred with a non-Jewish neighbor. Tom privately tells J.D. that he discovered long ago the strongbox was empty but swore on a prayer book never to reveal this.
Tom also befriends Basil Kokovinis, a Greek immigrant boy who arrives speaking no English. When the neighborhood bully, Sammy Leeds, exploits Basil's ignorance, Tom intervenes with his fists and teaches Basil English. Basil's father, George Kokovinis, who owns the Palace Cafe, promises Tom a silver dollar if Tom can help Basil stand up for himself. After learning from Papa that Greeks are historically great wrestlers, Tom teaches Basil to wrestle instead of box. In a rough-and-tumble rematch, Basil throws the bigger Sammy down and earns his respect and friendship.
When school resumes, the new teacher, Mr. Standish, replaces the retiring Miss Thatcher and institutes harsh corporal punishment. After Tom refuses on principle to inform on a classmate, Mr. Standish paddles him 10 times. Vowing revenge, Tom assembles 14 non-Mormon children and orchestrates an elaborate frame-up: Jimmie Peterson, whose mother runs Mr. Standish's boarding house, plants whiskey bottles and breath freshener in the teacher's room, while Tom plants a flask in Mr. Standish's coat pocket at school. An anonymous note tips off the schoolboard, and Mr. Standish is dismissed. That evening, J.D. inadvertently blurts out the truth, and Mamma presses Tom until he confesses. Papa takes Tom before the schoolboard, where Mr. Standish is reinstated. The teacher thanks Tom for coming forward and abandons corporal punishment.
The final episode centers on Andy Anderson, a boy whose left leg has been amputated below the knee after gangrene set in from stepping on a rusty nail. Excluded from games and taunted by other children, Andy tells J.D. he wants to kill himself. Taking this literally, J.D. twice attempts to help Andy die, but each attempt fails. Tom discovers what is happening, intervenes, and offers to prove Andy is not useless, in exchange for Andy's erector set. Over several weeks, Tom straps on the peg leg himself to develop techniques, then trains Andy to climb stairs, carry loads, do chores, and run. He builds Andy's confidence through Indian squaw wrestling, a game in which two players lie on their backs, lock legs, and try to flip each other over. On a climactic Saturday, Andy beats the neighborhood champion at wrestling, outruns J.D., and hits a game-winning home run.
When Andy arrives to hand over the erector set, Tom refuses it, saying it does not feel right to be paid for helping someone. Tom then returns J.D.'s Indian beaded belt, describing a feeling of being "clean and warm and Christmasy" inside. J.D. narrates that this event, occurring a week before Christmas, constitutes a miracle: The Christmas spirit, aided by a boy with a peg leg, has reformed Tom. Life grows dull as Tom gives up his scheming, so dull that Papa does not even check whether Tom is in bed the night the schoolhouse burns down, a detail hinting that Tom's reformation may already be unraveling.