The novel opens in the sad city in the country of Alifbay, where Haroun Khalifa lives with his father, a famous storyteller, and his mother. One day, Haroun arrives home from school to learn that his mother has run off with his upstairs neighbor. This neighbor had often been critical of Haroun's father, Rashid, because he did not understand the usefulness of stories. In anger, Haroun assails his father for the uselessness of his stories. This crushes his father. Haroun finds it difficult to concentrate on schoolwork and so his father decides to take him on a storytelling job he is performing for some politicos in the Land of G and the Valley of K. When Rashid attempts to tell his stories, however, no words come out, and the politicos get very mad.
Haroun and Rashid board a mail bus bound for the Valley of K. It is driven by a parrot-looking man named Butt who stutters and speaks in riddles. Rashid makes a deal with Butt to drive them on the dangerous road between the Land of G and the Valley of K. Butt drives dangerously and Haroun is worried that he will die. When they reach the beautiful sights of the Valley of K, Rashid tells Haroun that it all reminds him of "khattam-shud," an ancient concept that means silence. When they reach K, Haroun and Rashid meet Mr. Buttoo, the politician, who takes them to his boat on the Dull Lake. As they depart on the lake, they are engulfed in a thick mist.
The mist smells very bad and Haroun realizes that it is a Mist of Misery brought on by his father's foul mood. When the sea begins to rock, Haroun tells everyone to think good thoughts, and when they do, the sea calms. Haroun and Rashid reach the yacht that will take them to their destination the next day. The yacht is very luxurious, but both Rashid and Haroun have difficulty sleeping. Just as Haroun dozes off, he hears a noise in his bedroom. He finds an old man with an onion shaped head, who disappears as soon as he sees Haroun. The old man drops a wrench, which Haroun confiscates. The old man materializes and tells Haroun he is Iff, the Water Genie, and he must have the wrench to turn off the Story Stream for his father, Rashid. When Haroun protests, Iff tells him to take it up with the Walrus in Gup City, Kahani. Haroun demands that the Water Genie take him there, and Iff reluctantly concedes in order to get his wrench back from Haroun.
The Genie tells Haroun to pick a bird and give it a name and it will materialize. He pulls out a handful of tiny magical creatures. Haroun picks the Hoopoe and Iff throws it out the window and into the water where it balloons into a huge bird. They climb on its back and accelerate into space. The Hoopoe looks like Mr. Butt, so Haroun names it Butt the Hoopoe. They are able to communicate telepathically. Butt the Hoopoe lands on the Sea of Stories of Kahani, Earth's second moon, which moves so fast it is undetectable by human instruments. it evenly distributes Story Water across the earth. They land in the ocean so that Iff can give Haroun Wishwater and hopefully bypass meeting the Walrus.
Haroun drinks the Wishwater and wishes for his father's storytelling to return. He can only focus on an image of his mother, however, and after eleven minutes, he loses his concentration. Iff then gives Haroun a cup of water from the Sea that contains a story. Haroun drinks it and then finds himself looking through the eyes of a hero in a Princess Rescue story. As the hero climbs the tower to rescue the princess, he turns into a spider and princess hacks away at him until he falls to the ground. When Haroun wakes from his story, Iff tells him that someone named Khattam-Shud is poisoning the stories.
Haroun, Butt the Hoopoe, and Iff the Water Genie fly to the Land of Gup, where they meet Mali, the Water Gardner, and the Plentimaw fishes. The entire land is preparing for war. The Chupwalas have stolen Princess Batcheat from Gup. In addition, they have polluted the Sea of Stories so that many do not make sense anymore. Prince Bolo, General Kitab, and the Walrus announce their plans for war to the Pages of the Guppee Library (or, army). They bring in a spy with a hood over his head. When the hood is removed, Haroun sees his father.
Rashid tells everyone that he transported to Kahani and was in the twilight strip when he sas the Princess Batcheat captured. The Chupwalas have come under the spell of Cultmaster Khattam-Shud who wants to sacrifice her to Bezaban, an idol to silence. Prince Bolo and General Kitab declare war on Chup and Rashid offers to guide them to the Chupwala encampment. One of the soldiers in the army, Blabbermouth, takes Haroun to his room. They become lost and Haroun knocks the hat off Blabbermouth's head. Long hair falls out and Haroun sees Blabbermouth is a girl. She then entertains him with a juggling act.
The army sails towards Chup, chattering about the causes for the war in a way that Haroun thinks might be mutinous. They enter the land of Darkness and land on the beach. They explore the interior and come upon a dark warrior fighting his own shadow in a kind of seductive dance. The man realizes he is being watched and comes to find the trespassers. The shadow begins to speak. It croaks out unintelligible words until Rashid realizes the warrior is speaking in an ancient gesture language. Rashid interprets the warrior's talk. His name is Mudra and he had been second in command in Chup. He is now fighting against Khattam-Shud in order to bring peace back to Chup. Mudra agrees to help the Guppees defeat Khattam-Shud.
Haroun volunteers to spy for the army because of his love of stories. He, Iff, Butt the Hoopoe, Mali, and the Plentimaw fishes begin to trek towards the Old Zone. The water becomes so poisonous that the fish cannot go on. The remaining crew is suddenly ambushed and captured in nets. They are taken to a giant, black ship. On the deck are cauldrons of poison. To Haroun, it looks like everything is impermanent, like a shadow. Khattam-Shud appears and he is a tiny, weasly, measly man. Haroun realizes that this is Khattam-Shud's shadow that has detached from its owner. The Cultmaster tells them that stories are inefficient and useless and that is why they are being destroyed.
The ship's hull is full of darkness and machines To Complicated to Describe. The Cultmaster shows them where they are building a great Plug to seal the Story Source at the bottom of the Sea. Haroun sees roots growing through a port window and Mali appears, latching onto the generators and breaking the machines. Haroun breaks free, puts on a protective wetsuit, and dives down into the Sea where he sees the Plug being constructed. He returns to Butt the Hoopoe and takes out a vial of Wishwater given to him by Iff. He drinks it and wishes that the axis of Kahani would spin normally. A few minutes pass and then the entire land is bathed in sunlight. All of the shadows on the ship begin to fade away and soon everyone is free and the poison is destroyed.
In Chup, Khattam-Shud sends an ambassador to the Guppee army. The ambassador begins to juggle and pulls out a bomb. Only Blabbermouth's quick action keeps everyone from being blown up, but it is revealed that Blabbermouth is a girl in the process. Bolo tries to fire her, but Mudra asks her to be a part of his army because of her bravery. The battle between the army commences. Because the Guppees have had such open and honest communication, they fight as a team. The Chupwalas, because of their silence, distrust each other. The Guppee army overwhelms the Chupwala army. As the battle ends, there is a great earthquake and the moon begins to spin. The statue of Bezaban falls and crushes the real Khattam-Shud. Peace is declared and everyone receives a promotion within their rank. Haroun prepares to leave and is told that he must see the Walrus.
In the Walrus's office, Haroun learns that it is all a joke and that he is not in trouble. All his friends are there with him. The Walrus tells him that for his bravery he is to be given a happy ending to his story. Haroun doubts that this is possible, but he wishes for his city to no longer be sad. He wakes up back in the Valley of K where his father is preparing his political story. As he stands up to give it, his father tells the story of Haroun and the Sea of Stories. It is a story that the crowd loves and they turn against their autocratic leader, Mr. Buttoo.
When Rashid and Haroun return home, it is raining and they walk through it getting soaked. All of the people in the sad city are dancing and Haroun asks why. They claim that the city has remembered it's name, Kahani, which means "story." Haroun realizes that the Walrus has put a happy ending into the raindrops. When he arrives home, he finds his mother there, telling them that she made a mistake in running off with Mr. Sengupta. The next day, Haroun awakes to find it is his birthday and his mother singing in another room in the house.