Spain, 1944. Officially, Gen. Franco, leader of the Spanish Fascists, has won the Civil War and it has been over for five years. But a small group of desperate rebels fights on in the northern mountains of Navarra. Dreamy 10-year-old Ofelia (Ivana Baquero) moves to Navarra with her delicate, pregnant mother Carmen (Ariadna Gil), to become acquainted with her new stepfather, Captain Vidal (Sergi López), a sadistic Fascist officer under orders to rid the territory of the remaining few leftist rebels hiding in the forest without supplies.
On the way, her mother stops the limo caravan carrying her and Ofelia while she gets over a spell of sickness. During the stop Ofelia, who is fascinated by fairy tales, discovers an old tree carved long ago into the image of a woodlands deity. A huge winged insect (called a dragonfly in the English subtitles) emerges from the mouth of the idol and follows the car after it continues on its trip. Ofelia thinks the insect might be a fairy. After they reach the old buildings where Captain Vidal has established his headquarters, the insect leads Ofelia to an overgrown, tumbledown labyrinth behind the mill. In the heart of the labyrinth she meets an ancient creature of the woods that identifies himself as a faun (Doug Jones in an excellent characterization that is way scarier than the traditional mischievous Pan, the half-man half goat God of Nature according to the ancient Greek religion), who claims to know her true identity and destiny, being the princess of a fairy land who was lost in the human world after forgetting who she was. According to the faun, her true parents, the king and queen of the other world, have never stopped looking for her and that the labyrinth is the last of portals her father, the King, created in the search for her. But before returning to them, she must verify that she is really the missing daughter by completing three tasks before the moon grows full. And no one must know: not her ailing mother, or her new friend, Mercedes (Maribel Verdú), the housekeeper at Vidal's home who secretly supports and is aiding the loser's side (the guerrillas hiding in the forest). Mercedes' brother is one of them. She and the doctor (Álex Angulo) have been trying to help and supply the rebels as much as they can. The doctor gives some of the wounded rebels medicines and she secretly brings them food and letters from their loved ones.
The faun gave Ofelia a book that will give her instructions, but at first the book appears to consist of blank pages. When she is alone the instructions for the first task appear on pages she is looking at. For her first task, Ofelia has to kill a huge and gross toad who lives within a large hollow tree (which is dying because of the toad inside} by getting three stones into its stomach. She then must retrieve a key from the dead toad's stomach. She does it, but she becomes filthy and her pretty party clothes that her mother had brought especially for her to wear that evening for dinner, where she was to be formally introduced to the Captain and his guests. Her mother scolds her and she later is told off by Vidal.
When she looks at the book to get her next task the pages turn blood red and she discovers her mother is hemorrhaging. Ofelia gets help and her mother is put to bed, but the doctor is pessimistic. The Captain is certain the baby will be his male heir (implied that is because of his virility) and instructs the doctor to save the child and sacrifice the mother if necessary.
The faun scolds Ofelia because she has not yet done the second task. To restore her mother to health, the faun gives Ofelia a mandrake root, which she secretly places in a bowl of milk under her mother's bed to help her to stand her pregnancy. The mandrake root appears to become a living miniature baby after it is placed in the milk.
Ofelia's second task is to to use the key to get something guarded by a dangerous creature with eyes in his hands, where she will be tempted by an array of food set out on a banquet table. The faun insists she must refrain from giving in to temptation and eating or touching any of the feast food. After retrieving what she was to get, she can't resist temptation, brushes off the fairies trying to warn her, and eats some grapes, waking the creature up. She barely succeeds in getting out alive. Afterward the faun tells her she will not be allowed to return to her parent's realm, because she had disobeyed and some of the fairies he had given her in a container to help her were eaten by the monster because of her recklessness.
Mercedes had given the keys of the cellar where medicines and food are kept to her brother and friends. When one of the rebels (Iván Massagué) is captured, Vidal tortures him. The Captain wants the doctor to revive the prisoner so he can torture him some more. Instead, the doctor accedes to the prisoner request and gives him a lethal dose, killing him so that he doesn't suffer anymore and won't reveal anymore than he already has. Vidal shoots at the doctor in the back, having the final proof that he had been long supporting and helping the guerrillas.
The faun had instructed Ofelia that she had to regularly feed the mandrake root a drop of blood. While she is doing this, Vidal discovers Ofelia under Carmen's bed and pulls her out violently. Also, he throws the mandrake root into the fireplace. Immediately, Carmen's pregnancy goes violently bad again. As the doctor is dead, a military medic delivers a baby boy, but Ofelia's mother dies.
Vidal tricks Mercedes into revealing that she also has been helping the guerrillas, binds her and gathers his instruments of torture. But Mercedes has always kept a knife concealed in her apron and she manages to reach it, cut her bonds, and stabs the Captain in the back and in his shoulder, and slashes his face, but doesn't deliver a lethal blow. She runs out telling him to be careful because she "knows how to gut a pig" and heads for the woods.
The faun had returned to Ofelia and told her she has a second chance. She now has to complete the third task which is to bring her baby brother to the labyrinth. At the moment she sneaks into Vidal's room to get the baby, the rebels make a final attack. Ofelia sneaks into the Captain's room where he is patching his wounds. He discovers Ofelia but she grabs her baby brother and runs to the forest and into the labyrinth with him in her arms, followed by Vidal, who now knows she's helping the Republican guerrillas. Ofelia stops when reaching the labyrinth, where the faun, holding a dagger, tells her to give him her brother because some blood from an innocent is needed for her to become the princess again. She had been warned not to always trust a faun, distrusts him and refuses to hand over the baby.
Vidal sees her with the baby in her arms, talking to the air. He confronts her. He only wants the baby. She refuses. Vidal shoots her, leaving her for dead, and picks the baby up.
When Vidal turns back toward the buildings, he sees he is surrounded by Mercedes with a large number of armed guerrillas. They take the baby from him. Vidal looks at the watch his own father had broken on his deathbed to record the time of his death (which Vidal had repaired.) He asks Mercedes to tell the baby boy about his father, how dutiful he had been, and about the watch. Mercedes tells him the baby will never know who his father was. (We are left to assume the baby is going to be smuggled into allied-occupied France to be raised with a leftish ideology, which is Vidal's worst fear and final humiliation). The rebels kill Vidal at the moment he realizes his child will be raised up as one of those people he hates so much that he virtually didn't consider them human and has long tortured and killed without remorse.
Then, Mercedes tries to aid Ofelia, but it's useless: her eyes are open and she is apparently dead. In her final moments, right before dying, Ofelia dreams she has succeeded: the last task was the most important one. (An alternate interpretation is that she has already died and it is her spirit that returns to her other world realm.) The rightful princess had to refuse to allow an innocent baby's death. That's was the true third task and how she proved she was the real princess and can claim her right to the throne for all eternity at the fairy world, making it flourish with new energy.