After a man named Alderson is killed in a mysterious cube-shaped room, five strangers – Quentin, Worth, Holloway, Leaven, and Rennes – awaken and meet in another identical room. No one knows where they are or how they got there. Quentin informs the group that some rooms contain traps, which he discovered while exploring. Rennes, a convict who has escaped seven prisons, assumes each trap is triggered by a motion detector and tests each room by throwing one of his boots in first. The maze is beset by frequent tremors, and Leaven notices numbers inscribed in the narrow passageways between rooms. Rennes enters a room that he assumes to be safe and is killed when he is sprayed with acid, indicating that each trap uses different sensors to trigger them.

Quentin believes each person was chosen to be there: He is a divorced police officer, Leaven is a young mathematics student, and Holloway is a free clinic doctor, while the surly Worth says he is only an office worker. Leaven hypothesizes that any room marked with a prime number is a trap, and they find a mentally challenged man named Kazan, whom Holloway insists they bring along. Quentin injures his leg in a trapped room deemed safe by Leaven’s calculations, and tensions rise over personal conflicts and the ensuing mystery over the maze’s purpose. After being provoked by Quentin, Worth finally admits that he designed the maze’s outer shell—in the shape of a gigantic cube—for a shadowy bureaucracy, and guesses that its original purpose has been forgotten; they have been imprisoned within the maze simply to put it to use, otherwise it would only serve to be “pointless”.

Worth’s knowledge of the outer shell’s dimensions allows Leaven to determine that each side of the Cube is 26 rooms across and that there are 17,576 rooms in total. She then guesses that the numbers indicate the Cartesian coordinates of each room. The group moves toward the nearest edge as determined by her theory, but each of the rooms near the outer wall is trapped. Rather than backtrack, they travel silently through a room with a sound-activated trap. After Kazan makes a sound and nearly causes Quentin’s death, Quentin threatens Kazan. Holloway defends Kazan, and she and Quentin clash, with Holloway insinuating that Quentin may have been an abusive husband and likes young girls. When they reach the edge, Holloway scouts the darkened gap between the Cube and its outer shell but slips during another violent tremor; Quentin initially saves her but then lets her fall to her death.

Quentin becomes mentally unhinged; he attempts to persuade Leaven to join him in abandoning the others and makes a sexual advance, but she rejects him. Worth intervenes, but Quentin beats him savagely and drops him into another room through a floor hatch. There, the group finds Rennes’ corpse and are demoralized by the thought of having wandered in circles. Worth then realizes that the rooms move periodically throughout the Cube, which is the cause of all the tremors. Leaven also deduces that traps are not tagged by prime numbers, but by powers of prime numbers, and Kazan reveals himself to be an autistic savant[9] who can quickly do prime factorizations mentally. With Kazan’s help, Leaven guides the group to the bridge room that will lead them out of the maze. Worth ambushes and seemingly kills Quentin before leaving him behind. Kazan opens the final hatch, revealing a bright white light, but Worth declines to leave the Cube as he has completely lost his will to live.

As Leaven tries to convince Worth to join her, Quentin reappears, stabs and kills her with a hatch lever, and mortally wounds Worth while Kazan flees. As Quentin moves to kill Kazan, Worth grabs Quentin’s leg and pins him in the narrow passageway as the rooms shift again. Quentin is torn apart, and Worth crawls back to Leaven’s corpse to die next to her. Kazan slowly wanders into the bright light.