In an unidentified city of near-constant rain and urban decay, the soon-to-be retiring Detective William R. Somerset (Freeman) is partnered with short-tempered Detective David Mills (Pitt) who recently transferred to the department.The detectives investigate a series of murders relating to the seven deadly sins, such as an obese man who was forced to feed himself to death, representing "Gluttony". They find clues at each crime scene related to other deaths, and believe they are chasing a serial killer. A set of fingerprints found at the scene of the "Greed" murder — the fatal bloodletting of a rich attorney — leads them to an apartment where they find an emaciated man strapped to
a bed. Though he initially appears to be dead, it soon is discovered that the man has been kept alive and entirely immobile by the killer for exactly one year to the day; a drug dealer and child molester before his captivity, this victim represents "Sloth", and dies soon after from shock. Though unable to learn anything from the insentient victim, the detectives agree that the killer has planned these crimes for more than a year.
Somerset is eventually invited to meet Mills' wife, Tracy (Paltrow), who is unhappy with Mills' recent move to the city. Somerset becomes Tracy's confidante, and she meets with him after the first few murders. Upon learning that she is pregnant but has not told her husband, Somerset confides in her his fear that the city is no place to start a family, and reveals that he had ended a relationship years earlier after pressuring his girlfriend to have an abortion. Somerset advises her to not tell Mills if she plans to have an abortion; otherwise, if she decides to keep the child, "spoil that kid every chance you get".
Using library records, Somerset and Mills track down a man named John Doe (Kevin Spacey), who has frequently checked out books related to the deadly sins. When Doe finds the detectives approaching his apartment, he opens fire on them and flees, chased by Mills. Eventually, Doe gains the upper hand and holds Mills at gunpoint, but then abruptly leaves. Investigation of Doe's apartment finds handwritten volumes of his irrational judgments and clues leading to another potential victim, but no fingerprints. They arrive too late to find their "Lust" victim, a prostitute killed by an unwitting man wearing a bladed S&M device, forced by Doe to simultaneously rape and kill her. Some time later, they investigate the death of a young model whose face had been mutilated. Having chosen to kill herself rather than live with a disfigured face, she is the victim of "Pride".
As they return to the police station, Doe appears to them and offers himself for arrest, with the blood of the model and an unidentified victim on his hands. They find out that he has been cutting the skin off his fingers to avoid leaving fingerprints. Through his lawyer, Doe claims he will lead the two detectives to the last two bodies and confess to the crimes, or otherwise will plead insanity. Though Somerset is worried, Mills agrees to the demand. Doe directs the two detectives to a remote desert area far from the city; along the way, he claims that God told him to punish the wicked and reveal the world for the awful place that it is. He also makes cryptic comments toward Mills.
After arriving at the location, a delivery van approaches; Somerset intercepts the driver, leaving Mills and Doe alone. The driver hands over a package he was instructed to deliver at precisely this time and location. While Mills holds Doe at gunpoint, Doe mentions how much he admires him, but does not say why. Somerset opens the package and recoils in horror at the sight of the contents. He races back to warn Mills not to listen to Doe, but the killer reveals that the box contains Tracy's head. Doe claims to represent the sin of "Envy"; he was jealous of Mills' normal life, and killed Tracy after failing to "play husband" with her. He then taunts the distraught Mills with the knowledge that Tracy was pregnant. Somerset is unable to contain Mills as he unloads his gun into Doe, becoming the embodiment of "Wrath". After a catatonic Mills is taken away, Somerset is asked where he will be; he replies, "around".