In the Segowlee cantonment, the British living quarters in India during World War I, Rikki-tikki, a mongoose, is swept from his burrow by a flood. Rescued by Teddy, the young son of a British family, Rikki-tikki is nursed back to health and adopted by the family. At first, Teddy’s mother worries that Rikki-tikki might be too wild and would be dangerous to have around Teddy. Teddy’s father reassures her that mongooses are not only safe to have in a house, but excellent protectors against deadly snakes.
Rikki-tikki makes friends with some of the animals in the garden. There are two cobras, Nag and Nagaina, who terrorize the birds and other animals. Darzee, a bird who lives in the garden, and his wife have lost one of their fledglings to the snakes. Darzee begs Rikki-tikki to keep them and their children safe. Rikki-tikki decides he will kill the cobras, but first, he kills another deadly snake. It is his first kill, and his family are impressed. He is hailed a hero. This only makes Rikki-tikki want to kill Nag and Nagaina more. He feels responsible for the safety of the family and the garden animals.
One night, Nag and Nagaina plot to kill the human family. Nag falls asleep in the bathroom while he waits for the man to come in for his morning bath. Rikki-tikki watches and waits for the right moment, then attacks. The mongoose wins a terrible battle against the cobra. Teddy's father shoots Nag in two, only after Rikki-tikki has killed him, and throws the snake on the trash pile.
Rikki-tikki and Darzee’s wife make a plan to get Nagaina away from her eggs. Darzee’s wife fakes a broken wing, making a racket to distract the cobra. Nagaina leaves her nest of nearly-hatched eggs and begins to chase the bird. Rikki-tikki kills the unhatched cobras and Darzee's wife calls out a warning to him. Thinking the man killed her husband, Nagaina has cornered the entire family on the veranda.
Rikki-tikki brings one last unhatched egg and taunts Nagaina. She is frantic and begs for her baby back. With the snake occupied, the family escapes. Rikki-tikki knows that if he does not kill Nagaina, neither the family, nor the garden animals will ever be safe. He attacks and chases her into her underground den. Darzee sings a sad song, saying that Rikki-tikki must be dead, for nothing can beat a cobra in its own den. Rikki-tikki, however, emerges victorious, announcing that Nagaina will not return.
The family and animals rejoice. Rikki-tikki eats a huge celebration meal with the family, and settles down as the proud protector of his human family and garden-animal friends.