16-year-old Sarah Williams recites from a book titled "The Labyrinth" in the park with her dog Merlin but becomes distracted by a line she is unable to remember while being watched by a barn owl. Realizing she is late to babysit her baby half-brother Toby, she rushes home and is confronted by her stepmother Irene, who then leaves for dinner with Sarah's father Robert. Sarah finds Toby in possession of her treasured childhood teddy bear, Lancelot. Frustrated by this and his constant crying, Sarah rashly wishes Toby be taken away by the goblins. She is shocked when Toby disappears and Jareth, the Goblin King, arrives. He offers Sarah her dreams in exchange for the baby, but she refuses, having instantly regretted her wish. Jareth reluctantly gives Sarah 13 hours to solve his labyrinth and find Toby before he is turned into a goblin forever. Sarah meets a dwarfish man named Hoggle, who aids her in entering the labyrinth. She has trouble finding her way at first, but meets a talking worm who inadvertently sends her in the wrong direction.
Sarah ends up in an oubliette, where she reunites with Hoggle. After they are confronted by Jareth and escape one of his traps, the two encounter a large beast named Ludo. Hoggle flees in a cowardly fashion while Sarah befriends Ludo. After another riddle, she loses him in a forest. Hoggle encounters Jareth, who gives him a drugged peach and instructs him to give it to Sarah, calling his loyalty into question, as he was supposed to lead her back to the beginning of the maze. Sarah is harassed by a group of creatures called the Fireys, but Hoggle comes to her aid. Thankful, she kisses him, and Jareth magically sends them to the Bog of Eternal Stench as punishment, where they reunite with Ludo. The trio meet the guard of the swamp named Sir Didymus, an anthropomorphic fox, and his Old English Sheepdog "steed" named Ambrosius. After Ludo howls and summons a trail of rocks to save Sarah from falling into the bog, Didymus joins the group. When the group gets hungry, Hoggle gives Sarah the peach and runs away as she falls into a trance and begins to forget her quest. She has a dream where Jareth comes to her at a masquerade ball, proclaiming his love for her, but she rebuffs him and escapes, falling into a junkyard. After an old Junk Lady fails to brainwash her, she is rescued by Ludo and Didymus, outside the Goblin City near Jareth's castle. They are confronted by the gate guard, but Hoggle bravely comes to their rescue. Despite his feeling unworthy of forgiveness for his betrayal, Sarah and the others welcome him back, and they enter the city together.
Jareth is alerted to their presence and sends his goblin army to stop them, but Ludo howls and summons a multitude of rocks to chase the guards away, and they enter the castle. Sarah insists she must face Jareth alone and promises to call the others if needed. In a room modeled after M. C. Escher's Relativity, she confronts Jareth while trying to retrieve Toby. She recites the lines from her book that mirror her adventure to that point, but she still cannot remember the last line. As Jareth offers Sarah her dreams, she remembers the line, "You have no power over me!" Defeated at the last second, Jareth returns Sarah and Toby home safely and turns into a barn owl, flying away.