In a large city of near-constant rain, high levels of crime and urban decay, the soon-to-be retiring Detective William R. Somerset is partnered with short-tempered but more idealistic Detective David Mills who recently transferred to the department.
The events of the movie happen in the span of seven days. On Monday, the detectives discover an obese man who was forced to feed himself to death, representing "Gluttony." The next day, they discover a fatal bloodletting of a rich attorney, representing "Greed". The detectives find a set of fingerprints, as well as additional clues at both murder scenes, and believe they're chasing a serial killer relating to the seven deadly sins. Two days later, the fingerprints 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". Though unable to learn anything from the insensate victim, the detectives agree that the killer has planned these crimes for more than a year.
Tracy Mills is unhappy with their recent move to the city. She meets Somerset after the first two murders and he becomes Tracy's confidante. 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, 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, sparing Mills's life. 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 unwilling man wearing a bladed S&M device, forced by Doe to simultaneously rape and kill her, severely traumatizing the man. On Sunday morning, 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 goes to the police station 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, which is 7 p.m. 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 envious of Mills's 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, asking if Mills will kill him and become "Wrath". Somerset is unable to contain Mills as he repeatedly shoots Doe, killing him and completing Doe's "work". After Mills is taken away, clearly in a state of shock, Somerset is asked by his Captain where he will be, and replies, "Around. I'll be around." As the movie ends, and before the credits roll, Somerset can be heard paraphrasing a quote by Ernest Hemingway, "Ernest Hemingway once wrote 'The world is a fine place, and worth fighting for'...I agree with the second part."
An alternate ending was storyboarded through an artists rendition, but was never filmed. In the alternate ending, Somerset is able to convince Mills to hand over his gun, after Doe reveals that Tracy's head is in the box and that she was pregnant. Doe is angered by this, stating that Mills and Somerset are upsetting his "work", given to him by God. Doe demands that Somerset give Mills back his gun, but instead, Somerset points the gun at Doe. As John Doe screams "No!", Somerset kills him with Mills pistol, ending Doe's "work" before it is complete.