In an unidentified city of constant rain and urban decay, Detective William Somerset is preparing to retire and leave the horrors of the city. Before he does he is partnered with Detective David Mills, a cocky, young and short-tempered cop from a small town. The two investigate the murder of a highly obese man who was fed spaghetti until his stomach burst from a kick. Somerset investigates the murder while Mills is given the murder case of Defense Attorney Eli Gould, with GREED written in Gould's blood on the floor. Soon after, Somerset finds GLUTTONY written behind the obese man's fridge and theorizes that a serial killer is basing his crimes on the Seven Deadly Sins, with five more to go.
To give Mills and Somerset a chance to get along, Mills' wife, Tracy (Gwyneth Paltrow) invites Somerset over for dinner. After Tracy goes to bed, Mills and Somerset examine case evidence from the two scenes. They find a picture of Gould's wife with blood painted around the eyes. The Detectives have a distraught Mrs. Gould look at the pictures in a safe house and she notices an abstract painting that is upside down. Brushing powder on the wall behind the painting, Somerset finds fingerprints outlining the words "Help Me."
After running the fingerprints through AFIS, the prints are traced a day later to a pedophile named Victor, who escaped conviction for the rape of a minor due to the efforts of his lawyer: Eli Gould, the GREED victim. SWAT and the detectives raid his apartment to find Victor to be the SLOTH victim, having been bound to his bed for a year exactly, as evidenced by pictures at the scene; one taken every day from the day he is discovered. Remarkably, he is still alive but suffering from severe physical and mental deterioration. His hand was cut off to leave the prints. After asking to interrogate Victor in the hospital, the doctor says that his "brain is mush" and that his death is imminent anyway.
That evening, Tracy calls Somerset and requests that he meet with her. The next morning, Somerset meets Tracy in a diner where she tells him how miserable she is in "the city". At Somerset's urging, Tracy reveals the truth of her request to meet: she is pregnant, afraid of raising a child where they now live and afraid of telling her husband, David.
Later that day, and using a contact in the FBI, Somerset gets a library list of people who have borrowed books related to the Seven Deadly Sins. The list leads the detectives to a man named John Doe, whose apartment they visit soon after. Doe, his face hidden, sees them as he comes home and pulls out a gun. After a long chase, Doe hits Mills with a tire iron, keeps him subdued at gunpoint, but lets him live and suddenly flees. While examining Doe's apartment (after bribing a resident to claim she called the detectives about Doe) they find notebooks of his thoughts, trophies of the crimes and a picture of Mills fighting off Doe, who, at the time, was posing as a press photographer. They also find a photo of a young woman, a prostitute, who they believe may be the next victim. A receipt leads them to a S&M leather shop where Doe placed an order for a sexual device. The girl is soon found dead in a room with LUST written on the door. Also found in the room is a visibly shaken man forced by Doe at gunpoint to wear and use the device, a strap-on dildo with a blade attachment, to rape and kill the girl.
The next morning a model is found dead with PRIDE written on the crime scene. Doe cut off her nose ("to spite her face") and gave her the choice of suicide by sleeping pills or calling for help and living scarred. As the detectives return to the police headquarters, Doe walks up to them, his hands bleeding (he removed the skin from his fingers to avoid identification) and gives himself up. He talks to his lawyer and agrees that if he can take Somerset and Mills to two more bodies, he will confess to the murders. Wanting a confession, the detectives agree.
As the three travel to the desert outskirts of the city, Doe explains his rationale behind the murders as a way of showing people what the world is, as well as punishing the wicked. He goes on to say he will be remembered and admired for what he has done, while the disgusted Mills is driven to rage and screams at Doe while Somerset remains calmly worried.
Once they reach the outskirts, a van appears and Somerset stops it. The driver claims someone paid him $500 to deliver a box at this place and time. As Somerset opens the box, he recoils in horror from what he sees inside. As he screams to Mills and instructs him not to listen to Doe, Doe admits to Mills that he admires Mills' life, to the point of growing jealous of his wife and the love they share. He states that he tried to "play husband" with Tracy that day but it didn't work out and he took a souvenir instead: "her pretty head". It was Doe's plan that Mills kill him, as Doe himself was guilty of ENVY. He also reveals to Mills that Tracy was pregnant. Mills, despite the pleading of Somerset, is too shocked into tears by his wife's death and the knowledge that she was pregnant and empties his gun into Doe. Mills, by killing Doe in vengeance, comes to embody the sin of WRATH.
After a catatonic Mills is taken away, Somerset states that he will stay with the police department, eschewing retirement, feeling that if he quits, there will be nobody to stop the bad ones.