Adam, a photographer, awakens in a bathtub in a large dilapidated bathroom, and finds himself chained at the ankle to a pipe. Lawrence Gordon, an oncologist, is similarly shackled across the room, and between them is a corpse holding a revolver and a microcassette recorder. Each man has a tape in his pocket, and Adam is able to retrieve the recorder. Adam's tape urges him to escape the bathroom, while Lawrence's tape tells him to kill Adam by six o'clock, or his wife and daughter will be killed and he will be left to die. Adam finds a bag containing two hacksaws inside a toilet tank; they attempt to cut through the chains, but Adam's saw breaks and he throws it at the mirror in anger. Lawrence realizes the hacksaws are meant for their feet and identifies their captor as the Jigsaw Killer, whom Lawrence knows of because he was a suspect five months before.Flashbacks show that while Lawrence was discussing the terminal brain cancer of a patient, identified as John by an orderly named Zep Hindle, with his medical students, he was approached by Detectives David Tapp and Steven Sing, who found his penlight at the scene of a Jigsaw "game", of which at least three have been investigated. Lawrence's alibi clears him, but he reluctantly agrees to view the testimony of the only known survivor, a heroin addict named Amanda Young, who believes Jigsaw has helped her.Meanwhile, Alison and Diana Gordon are being held captive in their home by Zep, who is watching Adam and Lawrence through a camera behind a two-way mirror in the bathroom. The house is simultaneously being watched by Tapp, who has since been discharged from the force. Flashbacks show that Tapp became obsessed with the Jigsaw case after hearing Amanda's testimony, and eventually found Jigsaw's warehouse using the videotape from her game. He and Sing entered the warehouse, where they apprehended Jigsaw and saved a man from a drill trap, but Jigsaw escaped after slashing Tapp's throat, and Sing was killed by a shotgun trap while pursuing him. Convinced that Lawrence is Jigsaw, Tapp began stalking him after his discharge.In the bathroom, Lawrence finds a box containing a lighter, two cigarettes, and a one-way cellphone. He then recalls his abduction: he was trying to use his phone after being trapped in a parking garage, and was suddenly attacked by a pig-masked figure. They try to use a cigarette dipped in the corpse's "poisoned" blood to stage Adam's death, but the plan fails when Adam is zapped through his ankle chain. Adam then recalls his own abduction: he woke up in his photo development room to find the power was out and, after finding a puppet, was attacked by a similar pig-masked figure. At gunpoint, Alison calls Lawrence and tells him not to trust Adam, who admits he was being paid to take photos of Lawrence, many of which were in the hacksaw bag. Adam also reveals his knowledge of Lawrence's affair with one of his medical students; Lawrence had been with her before he was abducted. Lawrence realizes from Adam's description that Tapp was paying him. Adam finds a photo he didn't take, of a man staring out a window of Lawrence's house, whom Lawrence identifies as Zep. Unfortunately, the clock then strikes six as he realizes this.As Alison, who managed to free herself, calls Lawrence at gunpoint again, she fights Zep for the gun. The struggle gets Tapp's attention, and he saves the Alison and Diana and chases Zep to the sewers, where he is eventually shot during a struggle. Lawrence, aware only of gunshots and screaming, is zapped as well and loses reach of the phone; in desperation, he saws off his foot and shoots Adam with the corpse's revolver. Zep enters the bathroom to kill Lawrence, but is knocked down and beaten to death with the toilet tank cover by Adam, who only suffered a flesh wound. As Lawrence crawls out of the room to find help, Adam searches Zep's body for a key and finds another microcassette recorder, which reveals that Zep was another victim, following the rules of his own game to obtain an antidote for a slow-acting poison in his body. As the tape ends, the "corpse" rises and is revealed to be Lawrence's patient, John, the real Jigsaw Killer. He says the key to the chain is in the bathtub, which was drained when Adam awoke. He zaps Adam when he tries to shoot John and loses reach of Zep's pistol, and then John turns off the lights and seals the bathroom door leaving Adam to die, but not until after he tells him "Game Over".
Output: Question: With whom was Lawrence having an affair?, Answer: one of his students