The film opens with a hostage situation in South Dakota where FBI Agent Art Jeffries, who, as the inside man, protects a 15 year old kid named James while trying to talk a bank robber named Edgar Halstrom into surrendering. However, the FBI task force kills the robbers and James. Jeffries confronts his superior, Hartley, who tells him he'd report to Washington. An infuriated Jeffries punches Hartley for that and for James' death.
A cryptographic code called "Mercury" was created by the National Security Agency and allegedly so complex that its creators believe no computer on Earth can decipher it. Originally it was created during the Reagan Administration as a test to keep the United States' highest priority secrets under wraps. One day, the NSA receives a message from a nine-year-old autistic savant named Simon Lynch who calls a telephone number written in the code which was secretly published in a puzzle magazine by two of the creators, Dean Crandell and Leo Pedranski, to see if anyone could break it. Crandell and Pedranski's division chief, Lt. Colonel Nick Kudrow sees the boy's ability to decipher the code as a liability and rather than rectify the problem adequately, instead plans to silence Simon, sending a hit man, Peter Burrell and his partner Shayes to murder the boy and his parents, Martin and Jenny.
After shooting Martin and Jenny, Burrell searches the house, fails to find Simon, and leaves at the sound of approaching sirens (Martin was able to call 911 before dying). Jeffries, who has been demoted following a diagnosis of delusional paranoia, is sent to investigate what is initially thought to be a murder-suicide of Simon's parents. While investigating the scene, Jeffries finds Simon hiding in a cache of his bedroom closet and takes the boy under his wing. Jeffries begins to realize the difficulty of protecting, let alone questioning Simon, because of his impaired social abilities as a result of his autism, but the Chicago PD agree to assign a protection detail to Simon. Burrell tries to kill Simon again at the hospital, but Jeffries stops him. He is then forced to terminate an assassin named Shayes on the Chicago 'L' train. The situation is further complicated by the fact that nobody at the FBI believes Simon is in any danger, and Jeffries is soon framed by the NSA as a kidnapper, with only his best friend and fellow agent Tommy Jordan aware that he did not commit the crime, since Jordan had been in contact with Jeffries when the incident began. Despite his initial doubts, Jordan allows Jeffries to borrow his car but warns him that he'll have to report it stolen the following morning to avoid being implicated in this situation. Jeffries takes Simon to his house where his parents were murdered the previous morning. Simon again calls the telephone number written in the code, and, after realizing that Simon is talking to Crandell and Pendranski, arrangements are made for a meeting at the Wrigley Building. The next morning, he meets a woman named Stacey Siebring in a coffee shop and asks her to watch Simon for him while he goes to meet Crandell.
Jeffries meets Crandell and they talk as they walk on a busy sidewalk. As Crandell tells Jeffries about the code and Kudrow, Burrell shoots him from behind and escapes from Jeffries following a chase. After the shooting and getting Burrell's photo from a traffic camera, Jeffries goes back to the coffee shop, but Simon and Stacey are gone. He goes outside and spots them coming across the street. Stacey says she and Simon have become friends and Simon agrees. Jeffires and Simon then abruptly leave Stacey. Jeffries then meets with Jordan who delivers the information about Burrell's background as a Special Forces agent. While Jordan is now fully convinced this conspiracy is real, Jeffries doesn't want to involve him in this any further than he should. Later in the middle of the night, Jeffries and Simon go to Stacey's place, asking for a place to stay. Stacey reluctantly agrees and tells Jeffries that she was going on a business trip to Des Moines to make the rent the next morning.
Meanwhile, Pedranski turns to Jeffries for help, but shortly after he is murdered too by Burrell. However, he has managed to leave a letter detailing Kudrow's crimes, which he made two copies of, one to be sent to Jeffries and the other to the Senate Oversight Committee. Although Burrell got ahold of these letters, because he failed to notice the carbon paper used to type the letters that Pedranski threw in the trash, his girlfriend, NSA analyst Emily Lang, aware of the situation, recovers the carbon paper and takes them to the FBI hoping to find Jeffries. Learning about this from a receptionist, Jordan discreetly arranges for her to meet with Jeffries (by asking the receptionist not to log Emily's visit in) to show them both the carbon paper, which, being covered in Pedranski's fingerprints is crucial evidence in its own right.
After the meeting with Emily, Jeffries tells Stacey to call anybody for an emergency except the police, who were called off at the last minute during the hospital incident, and he gives her Jordan's number to contact if there was an emergency. Before leaving to confront Kudrow, Jeffries gives Jordan one of the carbon paper letters as a precaution while he keeps the other one with him. While Jeffries introduces himself to Kudrow at his birthday party and demands that Kudrow leave Simon alone, Jordan under Jeffries' suggestion arranges for Simon to go into Witness Protection. After the meeting, Jeffries contacts his friend and Jordan explains how the Witness Protection meeting is going to happen, though they are unaware that their conversation over the phone is being monitored by Kudrow. When Jeffries returns and finds Stacey and Simon gone, he learns from Jordan that they are fine and will meet them there, just as Jordan is given an order to head to the FBI director's office.
Kudrow tries to have FBI SAC (Special Agent in Charge) Joe Lomax help him stop Jeffries by using his authority and the fact that Jordan arranged the Witness Protection under false pretenses. He plans to have the NSA take over the protection for the meeting spot. After Kudrow leaves, Jordan shows the evidence to Lomax and despite his initial doubts, Jordan confirms that the fingerprint markings on it were Pedranski's, now fully validating the evidence against Kudrow. Jeffries, with Jordan and a small FBI task force's help, set a trap at the meeting spot. Stacey arrives at the meeting spot and gives Simon to Kudrow and Burrell who are posing as US Marshals.
Once Lomax who is in the building's security room gives the green light, Jordan and the FBI team move in and Kudrow orders Burrell to stall them. Jordan protects Stacey from the gunfire, while the FBI team take on Burrell, who gets killed when windows blow out and shards end up in his face. Meanwhile after taking Simon to the helicopter Jeffries appears from the helicopter and fights Kudrow on the roof. Simon gives the FBI agent Kudrow's own gun, allowing him to take control as Jordan and the team come in. In a last-ditched effort to get Simon back, Kudrow grabs the screaming boy and is shot by Jeffries, then falls to his death, but not before Jeffries grabs Simon out of his arms.
The film ends with Jeffries visiting Simon, now living with foster parents, at his school, who embraces Jeffries as a welcome friend, having finally accepted him as a person of his trust.