In 1905 Kansas, Oscar Diggs (nicknamed Oz) is a small-time circus magician and con artist in a travelling circus. He is early revealed to be a womanizer who tricks women by giving them a music box which he claims to have belonged to his dead grandmother, though in reality he has plenty of them. With his assistant Frank, Oscar runs a magic show where he mesmerizes the audience, but he is revealed to be a fraud when he is unable to heal a young girl who is unable to walk. Annie, a woman he is revealed to genuinely be in love with, visits Oscar at the circus to tell him another man, John Gale, proposed to her. Oscar, caring deeply for her and realizing he is a bad man, tells her she should accept. As a storm approaches the circus, the circus strongman attacks Oscar after finding one of his music boxes he had given to his girlfriend. Oscar escapes in a hot air balloon with his top hat and a sack of supplies but is sucked into a cyclone. As the balloon breaks apart, Oscar promises God that if he survives this he will become a good man.
Oscar finds himself in the land of Oz. The witch Theodora finds him and explains she believes he is the focus of a prophecy after seeing him perform a few simple magic tricks, which she believes are real magic. Theodora tells Oscar that the wicked witch Glinda killed her father, the wizard and king of Oz, but upon his deathbed, it was predicted that a great and powerful wizard by the name of Oz would descend from the sky, save the land, and become their new king. The duo follow the Yellow Brick Road to the capital, the Emerald City. Along the way, Oscar follows his womanizing ways and gives Theodora a music box; she clearly falls in love with him whereas he rebuffs such commitment. The duo encounter Finley (a reference to Frank, who he called his monkey), a flying monkey, and Oscar saves him from a lion with magical illusion. Finley pledges a life debt to Oscar.
In the Emerald City, the good witch Evanora, Theodora's sister, guards the throne until the prophecy wizard arrives. She is skeptical of Oscar being the wizard, but claims he can have all the power and wealth of the king if he kills Glinda by stealing and destroying her wand, the source of her power. Oscar and Finley travel to the Dark Forest, but along the way, they see smoke coming from "China Town", where the inhabitants are all made of porcelain. Everyone is dead except for a young, un-named girl whose legs are broken. Oscar fixes her legs with glue, and she explains that the wicked witch destroyed the city with her flying baboons because they celebrated Oscar's arrival to the land of Oz.
The trio travel to the Dark Forest and find Glinda, who resembles Annie in appearance and actions. However, just as they are about to destroy the wand, it is revealed that she is, in fact, the good witch and that Evanora is the true wicked witch and the one who killed the previous king. The army of the Emerald City and the flying baboons then arrive and attack Glinda, Oscar, Finley, and the China Girl. Glinda's magic allows the team to escape, first hiding them in a fog, then having them fly to Glinda's Castle, with a barrier strong enough to prevent Evanora from reaching it.
At her castle, Glinda reveals she knows that Oscar isn't truly a wizard but tells him he might be what they need. He tells the land he is the wizard here to save them, and he meets his "army": tinkers who can build anything, farmers who can grow anything, and munchkins that can create any clothing, all of whom are forbidden to kill. Theodora, now the Wicked Witch of the West, breaks the barrier and attacks the town, using her magic to manipulate Oscar's body like a puppet, telling Oscar that he is the cause of her wickedness. Glinda fights her off, but she says that she'll come back with the armies of the Emerald City. Oscar realizes he can't win against such an army with what is available and decides to leave, but he has a change of heart when the China Girl tells him that the old king used to grant wishes; she wishes to have her family back, but Oscar sadly realizes he can't help with this. He tells Glinda while they can't win in a straight-out battle against the Emerald City, they might be able to win through illusion. The town creates various objects for the upcoming battle.
Oscar and a few others sneak into the Emerald City in a magician's wagon with the help of the Emerald City's grumpy herald Nook, a secret ally of Glinda, during the attack, Glinda is captured. While this goes on, Oscar steals a large amount of gold from the Emerald City vaults and seemingly flies away with it in a hot air balloon. The Wicked Witch of the West shows this to the town and then destroys the balloon to destroy the city's hopes. This is simply an illusion by Oscar to make the town think he was dead so that he can be reincarnated as the Great and Powerful Oz, a wizard with no human form, which is really just a face projected onto smoke in the center of the city thanks to the wagon sneaked into the city earlier. The guards and witches attack, which of course has no effect.
As the witches grow fearful, Oscar "attacks" them and the city with fireworks, which they have never seen. In the confusion, Evanora runs into the palace out of fear, and China Girl brings Glinda her wand, allowing her to escape. Evanora and Glinda face off, with Glinda winning by destroying Evanora's emerald necklace, hinted to be the source of her power as its destruction causes her to lose her power and physically age. Evanora is banished from the Emerald City by Glinda, and she escapes by way of the two winged baboons.
The Wicked Witch of the West uses her broom to fly away in the ensuing confusion, and as she escapes, Oscar apologizes to the Wicked Witch of the West for what she has become and says she can come back if she ever regains her former self, but she declares that she will never go back. As she takes off, Oscar expresses sadness that he could not get through to Theodora who once believed in him.
Oscar creates a miniature version of his projection system, as he needs to make the citizens believe "Oscar" died but that Oz lives on in order to keep them united against the wicked witches. In keeping with the previous king, but unable to grant wishes, he gives the main characters of the story gifts. He offers the Master Tinker a type of Swiss army knife Oscar himself used in the film. Nook is given a mask with a smiley face. Finley is given something Oscar never gave anyone, his friendship (and hat). He gives the China Girl a new family in the form of her friends. He gives Glinda some sort of unspecified romantic relationship.
Robert Downey, Jr. and Johnny Depp were both offered the role of Oz. Downey wasn't interested in the playing the character; Depp liked the role but was already committed to The Lone Ranger (2013).