Benjamin Franklin Gates (Nicolas Cage) is an American historian, amateur cryptologist, and the youngest descendant of a long line of treasure hunters. While his father Patrick Henry Gates (Jon Voight) discourages him from following in the family line, Ben is driven on by a written clue given to him by his grandfather, John Adams Gates (Christopher Plummer): "The secret lies with Charlotte." According to family history, the clue—entrusted to the family by Charles Carroll of Carrollton in 1832—could lead to the fabled "National Treasure" fought over since Ancient Egypt and hidden by the Founding Fathers and Freemasons during the American Revolutionary War.
On an expedition led by Ben with computer expert Riley Poole (Justin Bartha) and the expedition's financier, Ian Howe (Sean Bean), the aforementioned team track down a colonial ship trapped in Arctic ice - the Charlotte. Inside the ship, Ben discovers a meerschaum pipe hidden in a barrel of gunpowder in the cargo hold. On the stem is an engraved riddle which he believes refers to an invisible map written by Timothy Matlack on the back of the Declaration of Independence. When Ian reveals he is willing to steal the Declaration, Ben takes a stand against him. In the ensuing fight, spilled gunpowder is ignited. Ian and his accomplice, Shaw, escape the ship, with the former locking Ben and Riley inside. Unknown to the others, Ben and Riley manage to escape the ship through a smuggler's hold before it explodes. They return to the United States determined to stop Ian.
When Ben and Riley report Ian's plan to steal the Declaration and the clue on the back of it to various authorities, including the FBI and Dr. Abigail Chase (Diane Kruger) at the National Archives, their claims are dismissed, stating that it is impossible and there is no clue. Ben then decides to steal the Declaration himself in order to prevent Ian from stealing it. Despite Riley's description of the security system guarding the document, Ben reveals his plan and convinces Riley that it can be done. After researching the system, Riley tests it by hacking in and activating the heat sensors triggering an alarm and a mechanism that lowers the Declaration to a subterranean Preservation Room. To gain the access code to the Preservation Room, Ben sends Abigail one of George Washington's original campaign buttons coated with invisible ink as a gift from a friend, knowing that when she types the access code, the invisible ink will mark the keys.
That night, Ben sneaks into a gala at the National Archives disguised as a janitor and obtains Abigail's fingerprint from a champagne glass, which he uses to access the elevator to the Preservation Room's hallway. After Riley disables the security cameras, Ben discovers her password by using chemicals to reveal the invisible ink on the keyboard. While Ben removes the Declaration from its case, Ian's team arrives, hacks the security system, and shoots at Ben who manages to escape via the elevator. At the gift shop upstairs, he is spotted with the Declaration by a cashier who thinks he's trying to steal one of the store's replicas. Ben is forced to pay for the document with his credit card. As he leaves, Abigail sees him and follows him outside, where she learns of their plan and quickly takes the Declaration from him and is kidnapped by Ian and his men who believe she has the Declaration. During the chase, Ben rescues her from Ian who soon realizes he has bought a replica along with the real one. Abigail still wants the Declaration to be returned, but Ben and Riley were able to force her to work with them to examine the clue.
While the FBI track Ben's identity through his credit card purchase, Ben, Riley, and Abilgail drive to Ben's father's house in Philadelphia, much to his father's surprise and dismay. When they examine the Declaration, Ben and Abigail discover an Ottendorf cipher on the back, which Ben believes to reference the Silence Dogood letters written by Benjamin Franklin. Ben's father once possessed these letters, but recently donated them to the Franklin Institute. Ben and Riley head to the museum, where they decode the message, which points to the steeple of Independence Hall—the original location of the Liberty Bell; however, Ian also makes the same deduction and heads there with his men. They enter the steeple at the time shown on the reverse side of a one hundred dollar bill—2:22. A shaft of sunlight points to a spot where Ben discovers a pair of spectacles with multiple colored lenses hidden inside a brick. The spectacles reveal an additional clue on the back of the Declaration—"Heere at the Wall"—which Ben believes is a reference to Wall Street and Broadway. When they notice Ian's men, they decide to split up.
Abigail and Riley lose the Declaration to Ian, and Ben is captured by FBI agent Peter Sadusky (Harvey Keitel). Abigail contacts Ian and offers him the next clue in exchange for his help rescuing Ben from the FBI. Under the pretense of an exchange, Ian lures the FBI to the USS Intrepid in New York City, where one of Ian's men intercepts Ben's mike, allowing him to escape by jumping overboard where another one of Ian's men helps him bypass the FBI. Ian returns the Declaration and pipe as promised. When Ben fails to reveal the entire clue, Ian shows that he's captured Patrick, forcing Ben to reveal additional information that points to Trinity Church. Inside the church, Ben reexamines the document and discovers yet another clue: "Beneath Parkington Lane." They soon discover a secret tunnel in the basement, which leads to a large shaft with an old staircase and elevator system. The staircase collapses as the group narrowly escape with their lives at the cost of Shaw's.
At the bottom of the shaft, they find a room lit by a lantern, which Ben and Patrick use to convince Ian that it signifies Paul Revere's Ride—a clue pointing to the Old North Church in Boston. Ian and his men leave Ben, Riley, Abigail, and Patrick stranded as they ascend to the surface, unaware that they've been given a false clue. Ben then pushes a button engraved on the wall of the "unfinished pyramid the all-seeing eye", which opens a passage to an empty room. Patrick sympathizes with Ben and admits that the treasure is real, and soon Ben discovers a panel on the wall with an engraving in the shape of the Charlotte pipe, which he uses to open another passage that leads to a vast chamber containing the National Treasure (which contained the scrolls from the Library of Alexandria) and stairs leading to the surface.
When the four ascend back to the church, Ben calls in the FBI and learns that Sadusky is a Freemason. The two arrange a deal: the Declaration will be returned in exchange for him, Riley, and Abigail being cleared of wrongdoing, and the Gates family and Riley being given credit for the discovery of the treasure to be distributed among the museums of the world. With the help of Ben, Ian and his men are captured by the FBI at the Old North Church and charged with kidnapping, attempted murder, and trespassing on government property.
Sometime later, Riley berates Ben for accepting a mere 1% finder's fee, despite having been offered 10%. Ben and Abigail are still able to purchase a mansion with their share, and Riley a Ferrari with his. As Riley drives away, Abigail hands Ben a map she's created, smiles, and runs off, with Ben chasing after her into the mansion.