Dorothy is near her home in Kansas and is searching for the way to Butterfield. She and her dog Toto first meet the Shaggy Man, a wandering hobo who carries the Love Magnet with him. He accompanies Dorothy on her journey for a while, and then the road to Butterfield splits into several paths. They take the seventh one and soon meet Button-Bright, a little boy in a sailor's outfit who's always getting lost. Then the companions meet Polychrome the Rainbow's Daughter, a fairy who danced off the edge of the rainbow just as it disappeared.
Dorothy, Toto, the Shaggy Man, Button-Bright, and Polychrome soon come to the town of Foxville where anthropomorphic foxes live. With a little prompting from King Dox of Foxville, Dorothy deduces that she's on another "fairy adventure" that will ultimately lead her to Oz, just in time for Ozma's birthday party (now acknowledged as August 21 by Oz fans, even though the book only refers to the 21st of the month). The king takes a particular liking to Button-Bright, and he magically confers upon the sailor boy the head of a fox for his cleverness. A similar event happens to the Shaggy Man, also non-maliciously, when King Kik-a-Bray of Dunkiton confers a donkey's head upon him -- also for cleverness, even though it's implied that Foxville and Dunkiton exist at odds with one another.
After meeting the Musicker and fighting off the head-throwing Scoodlers, Dorothy and her companions reach the edge of the Deadly Desert surrounding Oz, where Johnny Dooit builds a boat for them to cross the desert on. (This is necessary since physical contact with the desert sands will, as of this and Oz book three, Ozma of Oz, will turn the travelers to dust.)
Upon reaching Oz, Dorothy and her companions are welcomed by Tik Tok and Billina and come in their travels to the Truth Pond, where Button-Bright and the Shaggy Man regain their true heads by bathing in its waters. They meet the Tin Woodman, the Scarecrow, and Jack Pumpkinhead who also journey with them to the Emerald City for Ozma's birthday.
As preparations are made for arrivals from all over Fairyland (principally characters from Baum's non-Oz books, such as Santa Claus, Queen Zixi of Ix, and John Dough), the Shaggy Man asks for and receives permission to stay in Oz permanently. After everyone has presented their gifts and feasted at a banquet in Ozma's honor, the Wizard of Oz demonstrates a method of using soap bubbles as travel to send everyone home. Polychrome goes home with the arrival of a rainbow, Button-Bright goes home with Santa Claus on a soap bubble, and Dorothy is wished home by Ozma's use of the Magic Belt.