At the beginning of this story, it is made quite clear that Dorothy Gale (the primary protagonist of many of the previous Oz books), is in the habit of freely speaking of her many adventures in the Land of Oz to her only living relatives, her Aunt Em and Uncle Henry. Neither of them believes a word of her stories, but consider her a dreamer, as her dead mother had been. She is undeterred (unlike her alter ego in the film Return to Oz who is much perturbed by her guardians' doubts.)
Later, it is revealed that the destruction of their farmhouse by the tornado back in The Wonderful Wizard of Oz has left Uncle Henry in terrible debt. In order to pay it, he has taken out a mortgage on his farm. If he cannot repay his creditors, they will seize the farm, thus leaving Henry and his family homeless. He is not too afraid for himself, but both he and his wife, Aunt Em, fear very much for their niece's future. Upon learning this, Dorothy quickly arranges with Princess Ozma to let her bring her guardians to Oz where they will be very happier and forever safe. Using the Magic Belt (a tool captured from the jealous Nome King Roquat), Ozma transports them to her throne room. They are given rooms to live in and luxuries to enjoy, including a vast and complex wardrobe. They meet with many of Dorothy's animal friends, including the Cowardly Lion and Billina the Yellow Hen.
In the underground Nome Kingdom, the Nome King, Roquat, is plotting to conquer the Land of Oz and recover his magic belt, which Dorothy took from him in Ozma of Oz. After ordering the expulsion of his General (who will not agree to such an attack) and the death of his Colonel (who also refuses), King Roquat holds counsel with a veteran soldier called Guph. Guph believes that against the many magicians of Oz (the reputation of which has grown in the telling), the Nome Army has no chance alone. He therefore sets out personally to recruit allies.
Dorothy, accompanied by the Wizard of Oz and several other friends, departs the Emerald City in a carriage drawn by the Wooden Sawhorse, intending to give her aunt and uncle a tour of the land. Many of the people encountered have never been seen in other books:
The living cut-out paper dolls created by an immortal called Miss Cuttenclip.
The anthropomorphic jigsaw puzzles known as the Fuddles.
The loquacious Rigmaroles.
The paranoid Flutterbudgets.
The living kitchen utensils of Utensia.
The anthropomorphic pastries of Bunbury.
The civilized rabbits of Bunnybury.
A zebra who holds geographical disputes with a crab.
Other figures, more familiar to readers of previous books, include the Tin Woodman and the Scarecrow, as well as the four tribes of Oz (the Munchkins, the Quadlings, the Gillikins, and the Winkies).
The Nome General Guph visits three nations: the Whimsies, the Growleywogs, and the Phanfasms:
The Whimsies are large and hulking, but possess disproportionately small heads. This causes other species to call them stupid, stripping them of any self-esteem. To deny this, the Whimsies wear enormous, luridly designed masks that cover all of their heads.
The Growleywogs are muscular giants, possessing no surplus flesh and no mercy. They are arrogant and cruel. As such, they are eager not only to help the Nomes conquer Oz, but also to subjugate the Nomes as well. Of the latter plan, they say nothing, but send Guph on his way.
Last of his meetings is that which is with the mysterious, diabolical Phanfasms. To Guph, the Phanfasms resemble men, but having the heads of various carnivorous animals. Their true forms, number, standard of living, culture, and extent of influence remain unknown to both Guph and the reader, although both receive hints in the narrative. The Phanfasms send Guph home, telling him that they will conquer Oz alongside the other armies. It is their plan to do so, then to turn traitor and dominate their allies.
Having learned of this through Ozma's omniscient Magic Picture, the people of Oz become worried.
The climax takes place in the Emerald City, where Ozma wishes (using her magic belt) for a large amount of dust to appear in the tunnel. The Nome King and his allies are defeated after they drink thirstily from the Fountain of Oblivion and forget all their evil plans. Ozma uses the magic belt to send the Nome King and his allies home. To forestall a future invasion of Oz, Glinda the Good Witch uses a magic charm to render Oz invisible and unreachable to everyone except those within the land itself.

Question: How does Ozma ensure that the Nome King and allies forget their plans?
Answer: She causes dust to appear in the tunnel so they will drink from the Fountain of Oblivion
Alternative answer: They drink from the Fountain of Oblivion