During the autopsy of the Jigsaw Killer, John Kramer, a wax-coated microcassette is found in his stomach. Lieutenant Mark Hoffman is called in to listen to the tape, which informs Hoffman that he, too, will be tested as he is now "the last man standing."
The scene shifts to a mausoleum, where Trevor and Art are chained to a large winch. Trevor's eyelids have been sewn together, as has Art's mouth, making communication between them impossible. When the winch begins pulling them together, Trevor, out of panic, attacks Art, who kills Trevor to retrieve a key from the latter's collar. In a later flashback, Art finds two items waiting for him elsewhere in the mausoleum: a recorded message from Jigsaw and an envelope containing instructions.
It has been six months since the disappearance of Detective Eric Matthews, and four days since Detective Allison Kerry vanished, as noted by Hoffman. The police discover Kerry's corpse, still hanging in the harness of the inescapable trap that killed her in Saw III. After cautioning Lieutenant Daniel Rigg for barging through an unsecured door, Hoffman is introduced to FBI Agents Strahm and Perez, who deduce that Amanda Young, Jigsaw's apprentice, would need assistance with Kerry's trap, indicating that there is another accomplice to the murder.
That evening, Rigg is attacked in his home and Hoffman disappears. When Rigg comes to, a videotape informs him that Matthews is in fact still alive, with 90 minutes to save himself, and that Hoffman's survival is at stake as well. He then undergoes his first test, in which he finds a woman named Brenda. Jigsaw advises Rigg to walk away, and to "see what I see," as written on the wall, but Rigg's natural instinct to help those in need clouds his judgment. When Rigg removes the pig mask covering Brenda's face, he triggers a trap device that begins to slowly tear her scalp from her head. He succeeds in freeing her. To his surprise, she attacks him; Brenda has been told that Rigg is there to arrest her and the only way to stop him is to kill him. He throws her into a mirror and leaves to find the site of his next test. Some time later, Strahm, Perez, and the police enter the apartment and find Brenda dead.
Rigg arrives at a motel, where he is instructed to "feel what I feel," painted on the door of one room. He must abduct the manager, Ivan, revealed to be a serial rapist. Angered by seeing videos and photos of Ivan's crimes, Rigg forces Ivan into a prearranged trap at gunpoint, which gives him the option between having his eyes gouged out or being savagely dismembered. Rigg hands him two controllers that will drive blades into his eyes, blinding him and saving his life. When Ivan runs out of time after blinding only one eye, his limbs are ripped off his body and thrown across the room.
Rigg's next test, to "save as I save," occurs in a school where Rigg once attacked a man named Rex, whom he suspected of abusing his wife Morgan and daughter Jane. Hoffman had intervened to stave off disciplinary action against Rigg at that time. In one of the classrooms, Rigg discovers that same husband and wife impaled together back to back with several long metal rods. The rods are placed such that they pass through vital circulatory points of his body, but non-vital points of hers. If she has the courage to remove the rods, her abusive husband will bleed to death but she will survive. By the time Rigg finds the couple, she has pulled out all but one rod and gone into shock from blood loss; she suddenly wakes up and Rigg tells her that she has to save herself. He removes the last rod, hands her the key to the harness she and her dead husband are strapped into and sets off a fire alarm to alert emergency services to her position, then leaves.
Strahm and Perez arrive on the scene, having previously realized that they have both become targets in this latest series of games. They determine that all of the victims were defended by Art, who is also the lawyer of Jill Tuck, John Kramer's ex-wife. A gun used to insert the rods into Rex and Morgan fires a spear through a photographer and kills her on the scene. Strahm and Perez find Billy, Jigsaw's puppet, in the office, surrounded by candles. Perez is told via tape recorder that Strahm will "soon take the life of an innocent man" and that her "next step is critical." Ignoring the warning, she takes a closer look at Billy, whose face suddenly explodes and showers her with shrapnel; she is rushed to the hospital in critical condition. Furious, Strahm interrogates Jill, who recounts Jigsaw's back-story....
Jill was once pregnant with a boy to be named Gideon (after John's first construction project), but the baby was lost when Cecil robbed the clinic at which she was employed and caused her to suffer a miscarriage. She and her husband grew apart and divorced. After learning that he had cancer and only a short while to live, John kidnapped Cecil and placed him in a trap, the first trap he ever built. Cecil had to push his face against several knives in order to release his wrists and ankles, which were slit into razor blades in the arms and legs of the chair. The chair he was sitting in collapsed and he furiously lunged at John, who was standing in front of him watching. John sidestepped at the last moment, allowing Cecil to fall into a tangle of barbed wire. Strahm makes connections from Jill's story to the Gideon Meat Factory, the scene of Rigg's final test.
Strahm arrives but finds himself lost, accidentally trailing Jeff Reinhart, making the viewers believe that he is looking for his daughter. In reality, however, the events of this film and Saw III are now unfolding at the same time. Rigg, meanwhile, approaches his final test. In the next room are Art, Matthews, and Hoffman; Matthews stands on an ice block with a chain-noose cinched around his neck, while Hoffman is strapped into a chair with an electrode by his feet. They are at opposite ends of a balanced scale, but if Matthews slips off the ice or too much of it melts, he will be hanged and the weight shift will dump the runoff water onto Hoffman's end, electrocuting him. Art is watching over them both with a device strapped to his back that holds a set of pincers against his neck, ready to cut through his spine. Once the 90-minute timer for Rigg's tests runs out, he can push a button to release himself and the others. If the door is opened before time runs out, Matthews' head will be crushed between two overhead ice blocks and Hoffman will die with him.
Seeing Rigg approaching through the door's grimy window, Matthews attempts to warn him off without success, then shoots him with a gun supplied by Art. Though wounded, Rigg still crashes through the door with one second left on the clock, releasing the overhead ice blocks and killing Matthews. Rigg shoots and wounds Art, believing him to be responsible for the game. Art tries to explain the situation, but Rigg kills him, mistaking the tape recorder in his hand for a gun. The tape tells Rigg that he has failed his final test by not learning that he could not save everyone by himself; had he allowed the time to expire and not barged through the door, he would have passed and the three captives would have all survived. Hoffman releases himself from his chair unharmed, revealing himself to be another apprentice of Jigsaw, and leaves Rigg bleeding on the floor.
Meanwhile, Strahm faces off with Jeff in the makeshift sickroom from Saw III. Jeff waves a gun at Strahm, believing him to be involved in the abduction of his daughter; Strahm kills Jeff in self-defense, fulfilling Jigsaw's earlier warning. Before he can react further, Hoffman locks him in the room with the corpses of Jigsaw, Jeff, Amanda and Lynn.
The movie concludes with Jigsaw's autopsy, showing that it took place after the events of this film.