In a 1999 Philadelphia home invasion, Clarence James Darby (Christian Stolte) and his accomplice Rupert Ames (Josh Stewart) kill the wife and daughter of Clyde Alexander Shelton (Gerard Butler) before his eyes. Prosecutor Nick Rice (Jamie Foxx) is unable to use DNA hard evidence to securely convict both accused and unwilling to take a chance on lowering his high conviction rate. He makes a deal with Darby, letting him plead guilty to a lesser charge and receive a reduced sentence in return for testifying against Ames. Ames is found guilty and is sentenced to death. Darby is released after a few years. Shelton feels betrayed by Rice's actions and by the justice system in general.
Ten years later, Ames's time on death row is up. Unknown to the prosecutors and the witnesses, the cardiotoxic drug usually used in executions has been replaced with an anticonvulsant, causing Ames to die an extremely painful death. Evidence relating to tampering with the drug implicates Darby. An anonymous caller alerts Darby as the police draw near, and directs him to a remote location. Shelton, disguised as a cop, reveals himself as the caller and paralyzes Darby with puffer fish poison. He straps Darby to a table and slowly dismembers him, videorecording the gory proceedings. When Darby's remains are found, evidence ties his death to Shelton. Shelton willingly gives himself up and goes to jail.
Rice learns his wife and daughter were sent the dismemberment video and were traumatized by it, and initially refuses to bargain with Shelton to make a confession. But District Attorney Jonas Cantrell (Bruce McGill) orders Rice to make a deal. In court, Shelton represents himself. He successfully argues that he should be granted bail, then berates the judge for accepting the "bullshit" legal precedents he himself cited and for being too eager to let madmen and murderers back on the street. The judge jails Shelton for contempt of court.
Shelton demands a steak dinner be delivered to his cell by a specific time, in return for telling where to find Darby's lawyer, who was reported missing three days earlier. Rice agrees, though the dinner is delayed by a few minutes due to the warden's security measures. Once he has his meal, Shelton provides a set of coordinates, where Rice and the others find Darby's lawyer, buried alive but suffocated when his air supply ran out while Shelton's dinner was being delayed. Shelton kills his cellmate, forcing the warden to secure him in solitary confinement.
Cantrell arranges a meeting with a CIA contact and brings Rice. They learn that Shelton has previously worked with the agency, creating devices to assassinate people in imaginative ways. Further, they are warned that Shelton is capable of killing anyone he wishes. During a meeting with Rice and Cantrell, the judge is killed when she answers her cell phone and it explodes. A number of Rice's assistants are killed by car bombs, one of them Sarah Lowell (Leslie Bibb). As Rice and Cantrell leave the funeral of one of Rice's assistants, Cantrell is killed by a weaponized bomb disposal robot. The mayor (Viola Davis) puts the city under lockdown and promotes Rice to acting District Attorney.
Rice learns that Shelton owns an auto garage next to the prison. A tunnel from the garage leads to a cache of guns, disguises, and other equipment below the solitary confinement cells, and secret entrances to each cell. He realizes Shelton wanted to be in solitary, allowing him to easily leave the prison without detection and commit the murders. Evidence in the tunnel points Rice to Shelton's next target, city hall, where the mayor is holding an emergency meeting with city officials. Rice and his men cannot find Shelton, but discover evidence pointing to a cell-phone-activated suitcase bomb in the room directly below the meeting.
Shelton returns to his garage after planting the city hall bomb, then returns to his cell. He is surprised to find Rice waiting for him. Rice berates Shelton for taking revenge because of the pain he suffered. Shelton suggests another deal, but Rice refuses this time, saying that he does not make deals with murderers anymore, and thanks Shelton for teaching him that. Rice secures Shelton in the cell and flees. Despite being pleased that Rice had finally learned his lesson, Shelton dials the cell phone on the city hall bomb. Shelton realizes too late that Rice has moved the bomb to his cell and the cell's entrance to the tunnel has been sealed. Shelton looks upon his daughter's bracelet with a sense of sadness, accepting his fate as the bomb explodes.