Soon-to-retire detective William Somerset is partnered with short-tempered but idealistic David Mills, who has recently moved to the city with his wife Tracy. After forming a friendship with Somerset, Tracy confides to Somerset that she is pregnant and has yet to tell Mills, as she is unhappy with the city and feels it is no place to raise a child. Somerset sympathizes, having had a similar situation with his ex-girlfriend many years earlier, and advises her to tell Mills only if she plans to keep the child.

Somerset and Mills investigate a set of murders inspired by the seven deadly sins: a man forced to eat until his stomach burst, representing gluttony, and a defense attorney killed after being forced to cut a pound of flesh from himself, representing greed. Clues at the murder scenes lead them to a suspect’s apartment, where they find a third victim, a drug dealer and child molester, strapped to a bed, emaciated but alive, representing sloth. The third victim is in critical condition and in no way would be able to answer any questions asked from Somerset and Mills. Daily photographs of the victim, taken over a year, show the crimes were planned far in advance.

The detectives use library records to identify a John Doe and track him to his apartment. Doe flees and Mills gives chase, during which Mills falls from a fire escape and injures his arm. Mills searches a truck before being struck in the head with a tire iron. While he is incapacitated, Doe walks up and holds Mills at gunpoint for a moment before escaping. The apartment contains hundreds of notebooks revealing Doe’s psychopathy, as well as a clue to another murder. The detectives arrive too late to stop a man forced by Doe at gunpoint to kill a prostitute by raping her with a custom-made, bladed strap-on, representing lust. The following day, they attend the scene of a fifth victim, a model whose face has been mutilated by Doe; she was given the option to call for help and live disfigured, or commit suicide by taking pills, representing pride.

As Somerset and Mills return to the police station, Doe turns himself in, covered in the blood of an unidentified victim. Doe offers to take the detectives to the final two victims and confess to the murders, but only under specific terms, or he will plead insanity. Somerset is wary, but Mills agrees.

The detectives follow Doe’s directions to a remote desert location. Within minutes, a delivery van approaches. Mills holds Doe at gunpoint while Somerset intercepts the driver, who has been instructed to bring a box to them. Doe begins to taunt Mills by telling him how envious he was of his life with Tracy. Somerset opens the box and, in a sudden panic, warns Mills to stay back. Doe then says that his sin was envy, and that Tracy died as a result of this; he also states that her head is in the box, which is confirmed by Somerset’s silence, and that she was pregnant. Despite Somerset’s warnings, Mills fatally shoots Doe, completing Doe’s plan by representing wrath. Somerset and the police captain watch while the devastated Mills is taken away. Somerset offers his help for Mills. When the captain asks where he’ll be, Somerset simply says, “Around.” The ending is left open as to whether Somerset moves forward with his retirement or decides to remain as a detective.