The book is about Sam Gribley, a 12-year-old boy who intensely dislikes living in his parents' cramped New York City apartment with his eight brothers and sisters. He decides to run away to his great-grandfather's abandoned farm in the Catskill Mountains to live in the wilderness. The novel begins in the middle of Sam's story, with Sam huddled in his treehouse home in the forest during a severe blizzard. The reader meets Frightful, Sam's pet peregrine falcon, and The Baron, a weasel that Sam befriends. Roughly the first 80 percent of the novel is Sam's reminiscences during the snowstorm about how he came to be in a home made out of a hollowed-out tree, while the remainder of the novel is a traditional linear narrative about what happens after the snowstorm.
The second chapter opens with Sam Gribley remembering how he came to dislike living in New York City; how he learned of his grandfather's abandoned farm near Delhi, New York; how he learned wilderness survival skills by reading a book at the New York City Public Library; and about his trip to the small town of Delhi using $40 he earned by selling magazine subscriptions. Realizing his son will run away from home no matter what he does, Sam's father permits him to go to Delhi so long as Sam lets people in the town know that he is staying at the farm. Sam enters the forest near the town, builds a tent out of hemlock evergreen tree branches, and catches five trout in a nearby stream. But his survival skills are incomplete, and he is unable to build a fire. The next day, Sam searches for his grandfather's farm and fails to find it. However, he does meet Bill, a man living in a cabin in the woods. Bill teaches him how to make a fire. Sam is forced to go into town to learn where his grandfather's land is. He tells the local librarian who he is and where he is going, then journeys to the farm. Sam discovers the stone foundation for the long-destroyed farmhouse, but little else remains of the homestead.
Over the next several chapters, Sam continues to reminisce about how he came to be self-sufficient by living off the plants and animals he finds on his grandfather's abandoned farm. He finds a hollow tree and decides to make it his home. Remembering how Native Americans used fire to create dugout canoes, he uses fire to make the interior of the hollow tree bigger. One day, while Sam is chopping an ash tree to make a bed, an old woman named Mrs. Thomas Fiedler forces him to help her pick strawberries. Seeing a peregrine falcon hunting for its prey, Sam decides he wants a falcon as a hunting bird. Sam returns to town to get a haircut, and reads up on falconry at the local public library. He camps near a cliff for several days to learn the location of a peregrine falcon nest, and steals a chick from the nest while the mother bird attacks him. He names the bird Frightful, because of the difficult time he had getting the nestling. A short time later, Sam is forced to hide in the woods for two days. A forest ranger, spotting the smoke from Sam's cooking fire, came to investigate what he believed was a forest fire. The ranger lingers near Sam's home overnight, but leaves after believing that whoever started the fire must have left the place.
Sam also relates to the reader his memories about his adventures in the fall. He makes a box trap to catch animals to eat, but ends up catching a weasel instead. Sam calls the weasel The Baron for the fearless way the animal moves about the hollowed-out treehouse. Realizing winter is coming, Sam wants to kill a deer so he can make a door for his home. He learns how to smoke meat to preserve it for winter, and how to tan hides. When a poacher illegally kills a deer, Sam hides the carcass from the hunter so he can use it for food, a door, and a new pair of clothes. Sam remembers how he tanned the hide using a hollow tree stump and various plants. He also avoids townspeople who wander near his home by hiding in the woods. Sam trains Frightful to hunt, and the bird proves very good at it. Sam prepares for winter by hunting frogs, pheasants, rabbits, and sparrows; preserving wild grains and tubers; smoking fish and meat; and preparing storage spaces by hollowing out the trunks of trees. Finding another poached deer, Sam makes himself deerskin clothing to replace his worn-out city clothes. Sam notices a raccoon digging for mussels in the creek, and he learns how to hunt for shellfish. Sam names the raccoon Jesse Coon James, because it looks like a bandit and reminds him of the legendary outlaw Jesse James.
Shortly after befriending the raccoon, Sam hears sirens nearby. When he returns to his treehouse home, he finds a man there. At first, Sam believes the man is a criminal, and nicknames him "Bando" (a shortened version of "bandit"). But the man is a professor of English literature, and is merely lost. He is surprised to find Sam, and gives Sam the nickname "Thoreau". Bando spends 10 days with Sam, building a raft to take them downstream to catch fish. He gives Sam 10 pounds of sugar and teaches him to make jam. He also shows Sam how to make a whistle out of a willow branch. Bando also tries to make clay pots. Bando departs, and they agree that Bando will come back at Christmas to visit with Sam.
Sam remembers how, as winter came closer, he realized he needed to make a clay fireplace to keep his home warm. Sam steals two more dead deer from local hunters to make winter clothes, begins rapidly storing as many fruits and nuts as he can (trying desperately to get to them before the squirrels do), and builds his fireplace. Sam insulates his treehouse home too well, however: his fire generates too much carbon monoxide and not enough oxygen can get inside the treehouse. Frightful becomes sick with CO poisoning, which warns Sam. Sam puts ventilation holes in the walls of his treehouse to admit more fresh air. Sam feels lonely during Halloween, and makes a party for his animal friends—which goes badly when the animals start stealing his provisions. He tries to go into town to visit the library again, but is forced to climb a tree and stay there all day to avoid being discovered by hunters. He obtains two more deer; their carcases freeze in the winter cold, so he does not need to smoke them.
Sam feels lonely and visits the town again, where he gets a haircut and meets another teenage boy (Tom Sidler). On Christmas Eve, Bando finally arrives back at the mountain, showing Sam many newspaper articles about the "wild boy" living in the forest. On Christmas Day, Sam gets a surprise: Sam's father has come to visit. Sam is overjoyed to see his father again, and the three have a Christmas dinner of venison together. Sam's father is greatly relieved to find that Sam is doing just fine.
The novel ceases to be a flashback in Chapter 18, and becomes a straightforward narrative. Sam learns many things about how animals behave in winter, even during terrible storms. After the blizzard ends, Sam must still forage for food. He is happy that a Great Horned Owl has taken up residence on the farm, for it means that no people or building developments are nearby. Sam learns how Frightful and The Baron manage to survive during winter, helps the local deer find nourishment by cutting down tree branches for them to eat, and overcomes his own vitamin deficiency by eating the right foods.
After spring arrives, Matt Spell, a teenager who wants to become a reporter for the local newspaper, arrives at Sam's treehouse home. Matt wants to write about Sam's presence on the Gribley farm. At first, Sam lies to Matt and says the "wild boy" is someone who lives in a nearby cave. But Matt doesn't believe him. Sam then offers Matt a deal: Matt can come live with him for a week during school spring break, if Matt will not reveal his location. Matt agrees. After Matt leaves, Sam realizes he is very lonely and debates with himself whether he wants to be "caught" or not. A few weeks later, Sam encounters Aaron, a Jewish song writer who is visiting the forest for inspiration and singing a song. He tells Sam it is close to Passover, which makes Sam realize Matt will be visiting soon. Matt spends a week with Sam, mostly gathering food during this time. Matt is thrilled to be there, but Sam is sad because he realizes he is beginning to replicate his old life in New York City. Matt makes Sam even more unhappy by confessing that he told newspaper photographers where to find Sam. Bando arrives while Matt is visiting, and the two work on making one of the other trees into a guest house. A short time later, Tom Sidler discovers Sam living at the farm. Sam calls him "Mr. Jacket," and the two boys play for a while. Tom's visit makes Sam realize he is desperate for human companionship.
Bando returns to check on Sam, and Sam asks Bando to bring him some jeans and a shirt next time so he can visit his new friend Tom in town. In June, Sam is surprised one day to find that his father, mother, and all his siblings have arrived at the farm. His father announces that the entire family is moving to the farm. At first, Sam (now 13 years old) is overjoyed that his family has come to see him. But he is also upset, because it means the end of his life living off the land alone. Sam argues with his father about the family's decision. But his father says the family is as loyal to Sam as Sam has been to them, and that he will build a proper house for the family on the farm. Sam is especially upset about the decision to build a traditional home.
The novel ends as Sam meditates on the fact that, even if he went across the Pacific Ocean to get away from people, he still craves friendship and family. His journey in life, he decides, is about balancing his desire to live off the land with his desire to be with the people he loves.