In an unidentified city of constant rain and urban decay, Detective William Somerset (Morgan Freeman) is preparing to retire and leave the horrors of the city. Before he does so he is partnered with Detective David Mills (Brad Pitt), a cocky, young and short-tempered cop from Springfield, a comparatively small town. The two investigate the murder of a highly obese man (Bob Mack) who was fed spaghetti until a kick to his stomach burst him open. Somerset investigates the murder while Mills is given the murder case of Defense Attorney Eli Gould (Gene Borkan), with GREED written in Gould's blood on the floor. Gould was forced to carve a pound of flesh off of his body, and subsequently bled to death. The police captain gives Somerset an evidence container with three slivers of a plastic-like material found in the stomach of the obese man; which he was forced to consume along with the spaghetti. Going to the victim's house, Somerset finds three groove marks in front of the refrigerator and finds that the plastic-like slivers fit into them perfectly. He finds the word 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's wife, Tracy Mills (Gwyneth Paltrow) invites Somerset over for dinner. While they are eating, a train passes by on the track nearby, making the building and all its contents and inhabitants tremble: the couple mention that that's why the realtor was so nervous for them to see the apartment quickly. 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. Realizing that this means she is supposed to spot something about the murder scene that nobody else would, the detectives have a distraught Mrs. Gould (Julie Araskog) 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 (Michael Reid MacKay), 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 one year to the day, 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. Somerset advises her to tell her husband only if she decides to have it, and he sets himself as an example: he insisted his partner have an abortion, that he finally convinced her, and now he is remorseful.
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 (Kevin Spacey), whose apartment they visit soon after. Doe, his face hidden, sees them as he comes home, pulls out a gun and begins shooting. 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. John Doe calls the apartment and congratulates the detectives on them finding him and apologizes for hitting Mills. Their actions, he says, have caused him to change his plans. Then he hangs up. They also find a photo of a young woman, a prostitute (Cat Mueller), 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 (Leland Orser) forced by Doe at gunpoint to wear and use the device, a large strap-on dildo with a blade attachment, to rape and kill the girl. The owner of the place, Wild Billy (Martin Serene) can give no clue to the physical aspect or the briefcase John Doe used, as there every customer used to carry special clothes or equipment.
The next morning, a model (Heidi Schanz) is found dead with PRIDE written on the crime scene. Her nose has been cut off ("to spite her face") after Doe gave her the choice of suicide by sleeping pills or calling for help and living scarred. She chose the latter, Doe cut off her nose, after which she bled to death. As the detectives return to the police headquarters, John Doe (Kevin Spacey) 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 (Richard Schiff) and agrees that if he can take Somerset and Mills to two more bodies, he will confess to all the murders. Wanting a confession, the detectives agree. Somerset and Mills both have microphones taped to their chests so the rest of the task force can monitor their conversation with Doe. During the prep, Mills tries to tell Somerset about a concern he has with Tracy, but can't bring himself to talk fully about it.
As the three travel to the desert outskirts of the city in a car, they are trailed by a police helicopter for security (flown by John Santin and James Deeth). 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, having been "chosen" to do so. As Doe speaks, the disgusted Mills is driven to rage and screams at Doe while Somerset remains calmly worried.
Once they reach the outskirts, Doe directs them to a specific spot near some power cable towers. The detectives walk Doe out to an open spot. After a few moments, a van appears and Somerset stops it several hundred yards away, leaving Mills behind to cover Doe. The driver (Richmond Arquette) claims someone paid him $500 to deliver a box to Mills at this place at exactly 7 o'clock. As Somerset opens the box, he recoils in horror from what he sees inside. As he races back to Mills and desperately yells for him to throw his gun away, Doe admits to Mills that he admires Mills's life, to the point of being envious 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 will kill him, as Doe himself was guilty of ENVY, as he became jealous of Mills's simpler life. He also reveals to Mills that Tracy was pregnant, and that she begged to be kept alive for the child's sake. Mills, despite the pleading of Somerset, is so devastated by his wife's death and the knowledge that she was pregnant that he empties his gun into Doe. In killing Doe in vengeance, Mills comes to embody the sin of WRATH.
After a catatonic Mills is taken away, their captain asks Somerset what they should do for Mills, as the jury will condemn him. Somerset tells him "anything he needs." He also tells his captain that he will be "around", implying that he will be staying on the force. As the camera pans out from the desert, the movie ends with Somerset quoting Ernest Hemingway: "'The world is a fine place, and worth fighting for.' I agree with the second part."