Holes is a novel about a boy named Stanley Yelnats who is sent to a juvenile detention center called Camp Green Lake where the inmates are forced to dig holes in the desert. Stanley and his friend Zero gradually learn that they are actually digging for treasure, left by Kate Barlow, a Texas outlaw. After Zero runs away, Stanley goes off to rescue him and eventually recovers him. The two find the treasure, are released from defunct Camp Green Lake and return to their families.
Stanley Yelnats IV is a 14-year-old boy from a hard-working but poor family that is allegedly affected by a curse of bad luck, which they blame on at Stanley's "no-good-dirty-rotten pig-stealing-great-great-grandfather". Stanley's latest adversity is to be wrongly accused of stealing a pair of shoes contributed to a children's orphanage by the baseball player Clyde "Sweet Feet" Livingston.
As retribution, Stanley is sent to Camp Green Lake, a juvenile imprisonment and disciplinary facility which is ironically in the middle of a sterile desert. As a punishment, the inmates of the camp have to dig 1 hole a day 5 feet wide and 5 feet deep to 'build character'. Stanley soon begins to suspect that they are not digging to build character, but rather to find something hidden beneath the dry, rocky ground.
Stanley's "no-good-dirty-rotten-pig-stealing-great-great-grandfather", Elya Yelnats, is in love with a girl named Myra Menke, but a much older pig farmer named Igor Barkov also wants to marry her, offering Myra's father his heaviest pig in exchange for Myra's hand in marriage.
Desperate to impress Myra and her father, Elya goes to his friend Madame Zeroni for help. She warns him that Myra is not intelligent and will not be a good wife, and advises him to move to America, as her son has. She gives him a tiny piglet, telling him to carry the piglet up a mountain every day, and let it drink from a stream while singing to it. Each day the water will make it grow bigger, and Elya will grow stronger. On the last day, after he carries the pig one last time, he must carry Madame Zeroni herself up the mountain to do the same, as he will then be strong enough to carry her. However, Zeroni warns him that if Elya does not carry her up the mountain, his family will be cursed.
Elya follows her directions, and the piglet grows to a large size, but he does not carry the pig up on the final day in order to have time to clean up. Elya nearly wins Myra as his bride, but his pig is revealed to be the same weight as Igor's. Since the pigs weigh the same, Myra is given the choice between Elya and Igor, but fails to decide. When Myra has Elya and Igor try to guess what number she's thinking of in order to win her, Elya walks away in disgust. Elya, forgetting his promise to Madame Zeroni, moves to America to start a new life, falls in love, and marries, but he is beset by Zeroni's curse. The song that he sang to the piglet becomes a lullaby that is passed down among Elya's descendants, who are all named Stanley due to its palindromic relation to the name Yelnats.
In the year 1888, the town of Green Lake is a flourishing lakeside community. Katherine "Kate" Barlow, the local teacher, falls in love with Sam, an African-American onion seller, while rejecting advances from wealthy resident Charles "Trout" Walker (named due to the smell of his feet). There is an uproar in the town after Hattie Parker sees Kate and Sam kissing in an alley, proclaiming God will punish them. After no children arrive at the schoolhouse the following day, a mob led by Trout Walker ransacks and burns the schoolhouse. Kate realizes that Sam is in danger of being lynched and seeks the help of the sheriff. The sheriff is drunk and states that Sam is to be hanged in accordance with the law, but will spare Sam if she gives him a kiss. Kate leaves in disgust. She finds Sam and they attempt an escape across the lake in Sam's rowboat, but Walker and the mob intercept them with Walker's motorboat, ramming the smaller vessel and sinking it. Sam is shot and killed in the water, while Kate is rescued against her wishes. Following the death of Sam, no rain falls ever again on the town, and the reader is asked: 'who did God punish?'
Kate becomes outlaw who leaves a prominent kiss-mark in lipstick on her first dead victim, earning her the nickname "Kissin' Kate Barlow." Kate robs Stanley's great-grandfather, Stanley Yelnats I, of his entire fortune, but rather than kill him, she abandons him in the desert that was Green Lake. Miraculously, he survives.
Twenty years later, Kate returns to an old cabin on the former lakeside and is tracked down by Trout and his wife, who are bankrupt and desperate for money. They try to force her to reveal where she buried her loot, but she is bitten by a yellow-spotted lizard and dies. As she dies, she taunts them by saying, "start digging". The Walkers are left to dig the entire area in order to find the buried treasure.
The inmates at Camp Green Lake are forced to dig cylindrical holes five feet deep and five feet wide, which the warden says "builds their character." They are promised the rest of their day off if they find anything that the Warden considers "interesting". Stanley finds a fossil, but Mr Pendanski tells him that the Warden "isn't interested in fossils", leading Stanley to suspect they are looking for something in particular. During one dig, Stanley finds one of Barlow's lipstick tubes (though he doesn't recognize it for what it is), but he pawns it off to X-Ray, the ringleader of Tent D, who convinces him that he deserves it more than Stanley. The Warden is excited by the discovery and orders them to greatly enlarge X-Ray's hole (the wrong hole) and to sift through the dirt from it for several weeks.
Meanwhile, Stanley and Zero, the smallest inmate in Tent D, who got his nickname because "he has nothing in his head", become friends. Stanley agrees to teach Zero how to read, and in return, Zero digs Stanley's hole part of the time. The other boys eventually become jealous after seeing Stanley getting help, eventually resulting in a fight. The Warden and the staff arrive and, learning that Zero has been assisting Stanley with digging in return for receiving education, mock him. The argument culminates in Zero angrily hitting Mr. Pendanski with a shovel and running away, and the camp staff decide to erase their records of him and let him die in the desert. A few days later, Stanley follows Zero and finds him living under the remains of Sam's boat, eating very old jars of Kate's spiced peaches, which he calls "Sploosh". Stanley notices a mountain resembling a human fist giving the thumbs up sign, and recalls that Stanley Yelnats I claimed to find "refuge on God’s thumb". On the mountain, Zero admits that he was the one who stole "Sweet Feet" Livingston's shoes.
Atop the mountain, Stanley discovers a field of onions that was once Sam's. The boys eat the onions and find water by digging in the ground, and Stanley sings Madame Zeroni's song to Zero, Zeroni's descendant, unknowingly breaking the curse. Stanley suggests that they return to the hole where Stanley found the lipstick to find the buried treasure. They find a suitcase buried in the hole, but they are captured by the Warden, and surrounded by a group of lethal yellow-spotted lizards. A stalemate develops: they cannot move, but the lizards prevent the Warden's staff from approaching them. The lizards do not bite Stanley and Zero because they are repelled by the onions the boys have been eating. They remain in the hole until the next morning, when an attorney arrives demanding Stanley's release, having received testimony that gives him an alibi during the time the shoes were stolen. The Warden tries to claim they stole the suitcase from her, but Zero reveals that the name 'Stanley Yelnats' is written on it, as the suitcase had belonged to Stanley's great-grandfather. Fearing that the warden will kill Zero if he leaves him behind, Stanley refuses to leave the camp unless Zero can come along. The attorney orders the Warden to get Zero's file, but the camp staff are naturally unable to find it, and Zero is also released.
Stanley's family open the case, discovering the jewels, deeds, stocks and promissory notes stolen from Stanley Yelnats I. Using the money raised from the bonds, Stanley's family buys a new house and Zero hires a team of investigators to find his missing mother; meanwhile, the drought at Green Lake is brought to an end by rainfall. The family's luck seems to change as if in response to Stanley's fulfillment of his ancestor's promise (a suggestion left purposely ambiguous by the narration). In a final scene, Clyde Livingston and his wife, along with the Yelnats and Zeroni families, celebrate the success of Stanley's father's antidote to foot odor, composed of preserved and fermented spiced peaches and onions and named "Sploosh" by Zero. The Warden is forced to sell Green Lake to "a national organization dedicated to the well-being of young girls", which turns it into a Girl Scout camp.