In the 1960s, a young woman nicknamed Babydoll is institutionalized by her abusive widowed stepfather at the Lennox House for the Mentally Insane after she is blamed for the death of her younger sister. The stepfather bribes Blue Jones, an asylum orderly, into forging the signature of the asylum's psychiatrist, Dr. Vera Gorski, to have Babydoll lobotomized so she cannot inform the authorities of the true circumstances leading to her sister's death. During her admission to the institution, Babydoll takes note of four items that she would need to attempt an escape.
Babydoll slips into a fantasy world in which she is newly arrived in a brothel owned by Blue, whom she envisions as a mobster, where she and the other patients are sex slaves. In this realm, she befriends four other dancers – Amber, Blondie, Rocket, and Rocket's sister and "star of the show", Sweet Pea. Dr. Gorski is envisioned as the girls' dance instructor. Blue informs Babydoll that her virginity will be sold to a client known as the High Roller, who is actually the doctor scheduled to perform the lobotomy. Gorski encourages Babydoll to perform an erotic dance, during which Babydoll further fantasizes she is in feudal Japan, meeting the Wise Man. After she expresses her desire to "escape", the Wise Man presents Babydoll with weapons and tells her that she would need to collect five items: a map, fire, a knife, a key, and a fifth, unrevealed item that would require "a deep sacrifice" but bring a "perfect victory". She then fights three samurai giants. As her fantasy ends, she finds herself back in the brothel, her dance having impressed Blue and other onlookers.
Babydoll convinces the four girls to join her in preparing an escape. She plans to use her dances as a distraction while the other girls obtain the necessary tools. During her dances, she imagines fantastic adventures that mirror the escape efforts. These adventures include infiltrating a bunker protected by steampunk-inspired World War I German soldiers to gain a map (mirrored by Sweet Pea copying a map of the brothel/institution from Blue's office); storming an Orc-infested castle to retrieve two fire-producing crystals from inside a baby dragon (mirrored by Amber stealing a lighter from the mayor's pocket); and boarding a train and fighting robotic guards to disarm a bomb (mirrored by Sweet Pea stealing a kitchen knife from the Cook's belt). During the last fantasy, Rocket sacrifices herself to save Sweet Pea and is killed when the bomb detonates, which is paralleled by the Cook fatally stabbing Rocket while she tries to protect her sister.
Blue overhears Blondie relaying Babydoll's plan to Gorski, confirming his suspicions that something is amiss. He has Sweet Pea locked in a utility closet and confronts the other girls backstage. He shoots Amber and Blondie and attempts to rape Babydoll, but she stabs him with the kitchen knife and steals his master key. Babydoll frees Sweet Pea and starts a fire to keep the orderlies occupied while they look for an exit. They escape into the courtyard, where they find a throng of men blocking their way. Babydoll deduces that the fifth item needed for the escape is in fact her own sacrifice. She concludes that this is actually Sweet Pea's story. Despite Sweet Pea's protests, she insists on revealing herself to the visitors, thus distracting them long enough to allow her friend to slip away unnoticed.