The story recounts the “great war” fought between Rikki-tikki-tavi, a mongoose, and a pair of cobras in the garden of an English family living in the Indian province of “Segowlee.” Rikki-tikki’s name stems from his war cry, which he delivers as he runs through the tall grass.
One day, Rikki-tikki finds himself in the English family’s care after a flood washes him out of his burrow and onto the garden path of the family’s home. A young English boy, Teddy, finds Rikki-tikki and thinks that he has died, but Teddy’s mother suspects he is still alive. They take the mongoose into the house to dry him, and he soon recovers. Being without fear, like all his kind, Rikki-tikki begins to explore the house. He also climbs on Teddy’s shoulder, worrying Teddy’s mother, but Teddy’s father assures her that he won’t hurt Teddy; in fact, the mongoose provides protection from snakes. At night, Rikki-tikki sleeps in Teddy’s bed, though he ventures out and investigates whenever he hears a noise.
The next day, he sets out to explore the garden, which is still half-wild and overgrown. There, he meets a pair of tailorbirds—Darzee and his wife—who are crying over one of their babies who fell out of their tree. A cobra called Nag ate the chick, and no sooner do the birds mention the snake that he appears. Spreading his hood, Nag claims that the god Brahm gave him his black and white markings and tells Rikki-tikki to be afraid. At a sudden warning from Darzee, Rikki-tikki leaps into the air to avoid a sneak attack from Nagaina, Nag’s mate. He comes down on his back and bites her, but since he has little experience fighting cobras, he fails to land a killing blow. She’s left wounded and enraged, and the cobras vanish into the brush.
On the way back to the house, Rikki-tikki notices a baby cobra in the dust, Karait, threatening to bite Teddy. The baby is much quicker than his parents, making him more dangerous, but Rikki-tikki doesn’t know that and swiftly dispatches the baby before it can hurt the boy. Teddy’s father comes out to beat the corpse, which Rikki-tikki finds amusing since the snake is already dead.
Teddy’s family is quite grateful and the mongoose enjoys the attention, but he knows that the cobras are still out there. When the family goes to bed, he patrols the house, where he meets the fearful muskrat Chuchundra. He’s terribly afraid of Rikki-tikki, but he also carries a vital bit of knowledge that he reveals: the sound of snake’s scales can be heard moving across the bathroom sluice. Rikki-tikki follows the sound to the source, where he hears the two cobras plotting outside of the house. They intend to murder the humans, causing the mongoose to leave the home and allowing them to rule the garden along with their young. Nag crawls into a water jug to wait for Teddy’s father, unaware that the mongoose is nearby.
Rikki-tikki waits until Nag falls asleep, and then strikes at the base of his neck. He hangs on for dear life as the cobra tries to shake him off—only to be interrupted by a blast from Teddy’s father’s gun. Rikki-tikki is momentarily stunned, but Teddy’s father proclaims that the little mongoose has saved them all. Rikki-tikki drags himself back to Teddy’s room to sleep, awakening the next morning stiff but ready to take on Nagaina.
He returns to the garden, where word has spread about Nag’s death. Rikki-tikki asks Darzee to tell him where Nagaina’s egg nest is located, and then asks Darzee to feign injury to draw Nagaina away. Darzee doesn’t think it’s fair to attack the cobra’s nest, but Darzee’s wife sees the wisdom in Rikki-tikki’s plan and draws the cobra away from her nest by pretending that her wing is broken. The mongoose takes advantage of the distraction and destroys the eggs in the nest.
He’s almost finished when Darzee’s wife calls to him, claiming that Nagaina intends to kill Teddy and his family. Carrying the last egg as a bartering chip, Rikki-tikki runs back to the house, where Nagaina menaces the humans at their breakfast table. He distracts her with the final egg and avoids her strikes while Teddy’s father goes for his gun. Nagaina seizes her last egg and flees into her cobra hole, but Rikki-tikki bravely follows her down. Darzee thinks that is the end for Rikki-tikki, but he eventually emerges, having slain the cobra and saved the garden.
The animals in the garden sing the mongoose’s praises while he sleeps after his great battle. When he wakes up, he goes back to the house and enjoys food from the table and the affection of the humans. He remains on guard, however, and keeps the household free of snakes from that point on.