Everyone congratulates James on his terrific plan in Chapter 21. James also comforts Earthworm and assures him that he will not be pecked to death - James will be watching him the entire time. Time is of the essence, as the passengers observe 90 to 100 sharks attacking the peach from all sides. James orders everyone to their stations, and it is clear that he is the captain now. Everyone is ready to listen to whatever he tells them.
In Chapter 22, James' plan is ready to be put into action. Half of Earthworm's body is perched atop the peach, with James hidden just below the surface, waiting for the first seagull. The other creatures are down below in the peach, ready to pull the Earthworm down as soon as James gave the cue. James also holds a string of silk in his hands, and when the first seagull comes in to eat Earthworm, James calls for the others to pull Earthworm down and loops the silk around the seagull's neck.
James and his companions continue this process over and over again. Slowly they put silk ropes around the necks of 500 seagulls, but the peach still has not risen out of the water. Yet the sharks can anticipate that they are about to lose their prey, and they begin attacking more ferociously. Everyone can feel the peach slowly sinking into the sea. Silkworm and Miss Spider are not convinced that they can produce any more silk, but James urges them to keep trying. They manage enough to rope in a 501st seagull, and as James ties the silk around the gull's neck the peach lurches upwards, but the escape isn't yet assured. With the 502nd seagull, the peach takes off towards the heavens like a balloon.
In Chapter 23, everyone celebrates and dances as the peach flies into the air, safe from the sharks. Miss Spider volunteers to inspect the damage from the sharks, and when she returns she reports that there is barely any damage at all. None of the characters believes this, thinking that some sort of magic must have healed the peach, but the narrator briefly interrupts the story and explains that sharks have difficulty biting into large, round objects because of their protruding noses.
Then, the companions see a ship sailing below them, the Queen Mary, sailing to America. From the ship, the Captain and the rest of the crew can see a giant round ball hovering overhead, and they mistake it for a secret weapon. Using binoculars, the Captain reports that a boy in trousers, a giant ladybug, a colossal green grasshopper, a mammoth spider, and an enormous centipede are on the top of the peach. His crew begins to think he is crazy, and they call for the ship doctor to inspect him. Just then, the peach passes behind a cloud and the crew never sees the giant sphere again.
Everyone on the peach is very happy as, in Chapter 24, the seagulls carry the peach further and further into the sky. The Old-Green-Grasshopper offers to play music for everyone, and he uses his body as a musical instrument. Everyone loves the music, and James is incredibly surprised at what a talented musician the grasshopper is.
Then, in Chapter 25, James and his friends begin to learn more about one another. James learns that earthworms process all of the soil in all of the fields, that ladybugs are bought in bulk to help farms succeed, and that Miss Spider is frustrated with the public's dislike of her species. James also learns that the Centipede is widely considered a pest by society.
The plot line with the sharks continues to generate tension in this portion of the story; more than at any other point since they left the garden, all of the characters are anxious and nervous about their fate. As the pressure builds, James steps into his leadership role. He orders everyone to take on specific roles of their own in order to make his plan successful, and he knows that people will listen to whatever he says - a first in his life.
Chapter 22 builds off these ideas and raises a larger theme in the novel: teamwork. James's plan seems preposterous at first, but it succeeds because everyone works together and contributes a unique skill. If Earthworm hadn't been willing to bait the seagulls, the plan would not have succeeded - likewise for the silk production from Miss Spider and Silkworm, as well as the cooperation of the others, who pulled Earthworm back down into the peach on James's command. Every member of the team had trust everyone else, and without this trust and teamwork the peach might have been destroyed by the attacking sharks.
The characters are free from apparent danger in Chapter 23, but they still need to figure out for certain what is happening to them. When they realize the peach has not been harmed by the sharks, they revert to magic to understand their salvation, but magic is not responsible for the state of the peach - at least not this time. Magic certainly plays a large role in the James and the Giant Peach, but there is a simultaneous endeavor to understand through knowledge and logic that comes into play in this portion of the novel. This chapter quietly urges the reader to ask questions and investigate problems in order to comprehend the world.
In Chapter 24, Dahl uses an overwhelming number of analogies to describe the Old-Green-Grasshopper as a musician. These analogies also speak to humans' need to understand the world in uniquely human terms, which is how James understands the grasshopper's ear alignment and other aspects of the grasshopper's anatomy.
Chapter 25 reveals a great deal about understanding: from human understanding of animals to animal understanding of humans. James has some knowledge about the insects and their skills, but for the most part he relies on them to tell him more about their habits, contributions to humanity, and reception in society. Likewise, the animals rely on James to help move their conversation along: rather than simply lecturing James on her positive qualities, the Ladybug gently engages him in dialogue and draws out his earlier knowledge of her species. The creatures deserve praise not simply because they aid farmers and gardeners, but because they cultivate and nurture James.