Stanley and Zero spend one last day on God's Thumb, picking onions and planning their return to Camp Green Lake. On the way down the mountain, Stanley stumbles and falls, almost costing them their onions and water. They walk and walk until they reach the Mary Lou, with Zero telling Stanley anecdotes from his pre-Camp Green Lake life, during which he was homeless and slept in a park near Stanley's house, although the two boys never met.
As the sun sets, the boys approach the camp, and Stanley points out the hole where the treasure will probably be found. Once everyone in the camp is asleep, Stanley and Zero refill their water jars and start digging, eventually coming across a large, hard object which appears to be a "treasure chest" (201).
Suddenly, the boys hear the Warden's voice, and when they look up, they see Mr. Pendanski, the Warden, and Mr. Sir standing around the hole. Almost immediately, the six characters notice that the hole is teeming with yellow-spotted lizards. The boys are terrified, knowing that if they are bitten, they will die; the counselors are pleased that they'll have bodies to give to any inquiring authorities. Stanley learns that he was proved innocent while he was gone, and his lawyer came to Camp Green Lake to pick him up, but had to leave empty-handed. The stand-off between counselors, boys, and lizards continues until the camp's wake-up time, with both boys still miraculously alive. The camp's normal digging activities are suspended for the day, and Stanley and Zero stay in the hole waiting to die.
Cars pull up, containing, among others, the Attorney General and Stanley's lawyer (although he doesn't know how his parents managed to afford her). The lawyer is furious with the Warden, and threatens to file charges against her if the boys don't make it out of the hole alive. Stanley finally summons the courage to pull himself - and then Zero - out of the hole. The Warden tries to seize the suitcase with the treasure inside, but Zero points out that it has Stanley's name on it. The Warden cannot believe it, but it's true: STANLEY YELNATS is written on the suitcase, which was originally stolen from Stanley's great-grandfather.
Back at the camp, the Warden tries to bully the boys into opening the suitcase and showing her what's inside, but Stanley and his lawyer refuse to grant her wish. The Attorney General tells Stanley that he is free to go, but Stanley says he "can't leave Hector" behind (219). The Warden is unable to produce Zero's records - which she destroyed after he ran away - and Stanley's lawyer decides to take him back to the city along with Stanley. The other boys from D tent appear, wishing their friends well and warning them to be careful "out in the real world" (221).
There is one final flashback to the town of Green Lake at the beginning of Chapter 49. Sam the onion man is approached by three men who want to buy some of his "lizard juice," a mixture made of onions that protects against yellow-spotted lizards (223). Sam tells the men that the "lizards don't like onion blood," which explains why Stanley and Zero were unharmed by the yellow-spotted lizards when digging for the treasure (224).
In the car on the way back to Stanley's home, Stanley's lawyer tells Stanley that his father is in the process of patenting a cure for foot odor - he has finally been able to create an invention that will make the family comfortably wealthy. The boys note that the product smells "familiar," like peaches (225). As the boys drift off into sleep, it starts to rain for the first time in a hundred and ten years.
Stanley has a flashback on the point of death to "when he was very little" and fell down an icy hill with his mother (209). This memory is surprisingly ambivalent, as are the details he remembers: there is the "sharp coldness of the snow," the "light-headed feeling" of rolling down the hill, and the image of his mother's "bright and cheery face" (209). Stanley tells us that "he almost cried, but instead he laughed" and then he and his mother rolled down the hill again, on purpose, and got hot chocolate together (209). It is a strange memory for his mind to go back to, but it seems to suggest that he wants to be in control of his death (e.g., by rolling down the hill on purpose the second time around) and that it isn't anything to be frightened of although it seems scary at first. In this sense, Stanley demonstrates a lot of maturity in this scene, not least because he refuses to panic when he sees himself faced with almost certain death.
Zero comes into his own during the second half of the book, starting with his bold escape from Camp Green Lake. He relies on Stanley's help to get up the mountain despite being weakened by thirst, and he owes his life to his friend. In the scene of the stand-off between boys, lizards, and counselors, Zero gets the chance to show the adults that they all underestimated him. Zero was taunted and mocked by both Mr. Pendanski and the Warden for not being able to read and thus being worthless. Now, Zero's reading wrenches the Warden's treasure from her grasp at the last minute and gives it to its rightful owner: Stanley. Characteristically, when the Warden tells Zero one last time that he "can't even read," Zero simply says nothing (217). He doesn't need to prove himself to her.
We also see the solidarity between the boys firmly cemented. Zero and Stanley had a rough start. Stanley initially judged Zero more or less like the other boys did, but after their reading lessons they became closer, and when they became outlaws together the bond between them strengthened further. Stanley saved Zero's life, and they worked together to survive the trek back to camp. This closeness culminates with Stanley refusing to leave Zero behind at Camp Green Lake, insisting that he must be freed as well. The bond between the boys is physically manifested in their repeated hand-signal: a thumbs-up. This symbolizes the time they spent together on God's Thumb, and all the hardships that they overcame as a pair.
The flashback in Chapter 49 answers a mystery in the preceding chapters: how do Stanley and Zero survive in the lizard-infested hole, when by all rights they should have been bitten and killed? It is interesting that only the reader is privileged with this information; in the boys' minds it is never explained and remains a miracle. The past, although it influences and can help explain the present, also is confined, and only an omniscient narrator can see all the linking threads between past and present.
The pathetic fallacy reappears at the very end of Part Two, just as it opened the section. As the boys leave Camp Green Lake, the desert experiences the first drop of rain "in over a hundred years" (225). This symbolizes a new era for Green Lake, and a break with the horrors of the past. Sam's death caused the rain to stop, and the boys' survival and freedom has broken the curse, in some sense, and caused the rain to fall again.