Dorothy Gale sets sail for Australia with her ailing Uncle Henry, but a violent storm sweeps her overboard while she tries to rescue a chicken. Clinging to a wooden hen-coop, she drifts ashore in the unfamiliar Land of Ev, accompanied by a yellow hen named Billina who has mysteriously learned to speak. They encounter the mischievous Wheelers, who roll about on their hands and feet and try to frighten strangers, and they rescue Tiktok, a copper mechanical man created by Smith and Tinker who requires winding to think, speak, and act.
The travelers learn that the royal family of Ev—a queen and her ten children—have been enslaved and transformed into inanimate objects by the Nome King, after the former king sold them in exchange for a short-lived bargain before drowning himself. Princess Langwidere, who rules a portion of the palace and changes her appearance daily by swapping thirty different heads, rudely locks Dorothy away. Fortunately, the young ruler Ozma of Oz arrives across the deadly desert on a magic carpet, accompanied by the Scarecrow, the Tin Woodman, the Cowardly Lion, the Hungry Tiger, and a twenty-seven-man army composed almost entirely of officers.
The party journeys to the underground domain of the Nome King to demand the release of the captives. The king tricks them with a cruel wager: Ozma and her followers are allowed eleven guesses to identify the transformed royalty among thousands of palace ornaments, but failing means being turned into bric-a-brac themselves. Ozma and all the officers fail one by one and are magically transformed. Only Dorothy succeeds in saving one little prince, while the rest seem lost.
However, Billina the hen, having overheard the king's secrets about his purple-colored enchantments while hiding beneath his throne, successfully guesses and restores the entire royal family of Ev and all the transformed Oz residents to their true forms. When the Nome King threatens them with his army, the Scarecrow uses the hen's fresh eggs—which are fatal poison to the rock Nomes—to rout the enemy. Dorothy strips the king of his magic belt, restoring power to the rightful rulers.
After a joyful reunion where the missing Tin Woodman is recovered from a little boy's pocket where he sat as a tin whistle, the Queen of Ev crowns her eldest son. Ozma, Dorothy, Tiktok, and Billina cross the magic desert back to the Emerald City, where Dorothy is honored as a princess. Though she eventually uses the magic belt to return to Australia and care for her uncle, her heart remains connected to the magical realms.