Louvre curator and Priory of Sion Grand Master Jacques Saunière is fatally shot one night at the museum by an albino Catholic monk named Silas, who is working on behalf of someone known only as the Teacher, who wishes to discover the location of the "keystone," an item crucial to the search for the Holy Grail. After Saunière's body is discovered in the pose of the Vitruvian Man, the police summon Harvard Professor Robert Langdon, who is in town on business. Police Captain Bezu Fache tells him that he was summoned to help the police decode the cryptic message Saunière left during the final minutes of his life. The note also includes a Fibonacci sequence left out of order, as a code. Langdon explains to Fache that Saunière was a leading authority in the subject of goddess artwork and that the pentacle Saunière drew in his own blood represents an allusion to the goddess and not "devil worship", as Fache believes.
A police cryptographer, Sophie Neveu secretly explains to Langdon she is Saunière's estranged granddaughter, and that Fache thinks Langdon is the murderer, because of the note her grandfather left saying to "find Robert Langdon," which she says Fache had erased prior to Langdon's arrival. Sophie is troubled by memories of her grandfather's involvement in a secret pagan group. However, she understands that her grandfather intended Langdon to decipher the code, which she and Langdon realize leads them to a safe deposit box at the Paris branch of the Depository Bank of Zurich, which Sophie and Langdon go to after escaping the police. In the safe deposit box they find the keystone: a cryptex, a cylindrical, hand-held vault with five concentric, rotating dials labeled with letters that when lined up properly form the correct password, unlocking the device. If the cryptex is forced open, an enclosed vial of vinegar ruptures and dissolves the message, which was written on papyrus. The box containing the cryptex contains clues to its password.
Langdon and Neveu take the keystone to Langdon's friend, Sir Leigh Teabing, an expert on the Holy Grail. There, Teabing explains that the Grail is not a cup, but the tomb containing the bones of Mary Magdalene. The trio then flees the country on Teabing's private plane, on which they conclude that the proper combination of letters spell out Sophie's given name, "SOFIA." Opening the cryptex, they discover a smaller cryptex inside it, along with another riddle that ultimately leads the group to the tomb of Isaac Newton at Westminster Abbey.
During the flight to Britain, Sophie reveals the source of her estrangement from her grandfather, ten years earlier. Arriving home unexpectedly from university, Sophie clandestinely witnesses a spring fertility rite conducted in the secret basement of her grandfather's country estate. From her hiding place, she is shocked to see her grandfather making love to a woman at the center of a ritual attended by men and women who are wearing masks and chanting praise to the goddess. She flees the house and breaks off all contact with Saunière. Langdon explains that what she witnessed was an ancient ceremony known as Hieros gamos or "sacred marriage".
By the time they arrive at Westminster Abbey, Teabing is revealed to be the Teacher for whom Silas is working. Teabing wishes to use the Holy Grail, which he believes is a series of documents establishing that Jesus Christ married Mary Magdalene and bore children, in order to ruin the Vatican. He compels Langdon at gunpoint to solve the second cryptex's password, which Langdon realizes is "APPLE." Langdon secretly opens the cryptex and removes its contents before destroying it in front of Teabing. Teabing is arrested by Fache, who by now knows that Langdon was innocent. Bishop Aringarosa, realizing that Silas has been used to murder innocent people, rushes to help the police find him. When the police find Silas hiding in an Opus Dei Center, he assumes that they are there to kill him, and he rushes out, accidentally shooting Bishop Aringarosa. Bishop Aringarosa survives but is informed that Silas was found dead later from a bullet wound.
The final message inside the second keystone leads Sophie and Langdon to Rosslyn Chapel, whose docent turns out to be Sophie's long-lost brother, whom Sophie had been told died as a child in the car accident that killed her parents. The guardian of Rosslyn Chapel, Marie Chauvel Saint Clair, is Sophie's long-lost grandmother, and the widow of Jacques Saunière. It is revealed that Sophie is a descendant of Jesus Christ and Mary Magdalene. The Priory of Sion hid her identity to protect her from possible threats to her life.
The real meaning of the last message is that the Grail is buried beneath the small pyramid directly below the inverted glass pyramid of the Louvre. It also lies beneath the "Rose Line," an allusion to "Roslyn."