Following his discovery of the body of his wife in a bathtub after her suicide, Dr. David Callaway (Robert De Niro), a psychologist working in New York City, decides to move with his 10-year-old daughter Emily (Dakota Fanning) to upstate New York. There, Emily makes an apparently imaginary friend she calls "Charlie". Her friendship with Charlie begins to disturb David when he discovers their cat dead in the bathtub, whom Emily claims was a victim of "Charlie". Meanwhile, David suffers from nightmares of the New Year's Eve party that occurred the night before his wife died.
When a family friend, named Katherine (Famke Janssen), comes to visit David and Emily, Emily reveals that she and Charlie have a mutual desire to upset her father. Soon, they meet a man and a woman who are their neighbors. David is wary of their unusual interest in Emily. He later discovers that the reason for this is that the couple had a daughter who recently died from cancer and looks like Emily. Later, when David visits the woman, she nervously and ambiguously implies that her husband has begun abusing her in response to their child's death, emotionally and perhaps even physically.
David meets local woman, named Elizabeth (Elisabeth Shue) and her niece, Amy, who is roughly the same age as Emily. Hoping to cultivate a new, healthy friendship for Emily, David sets up a playdate for her. Amy is anxious to become friends immediately, but the playdate is spoiled when Emily cuts up Amy's doll's face. After Amy runs out of the house, Emily tells David that she doesn't need any more friends.
Despite the unsuccessful playdate, David and Elizabeth hit it off. David invites her over to dinner one night, where Emily acts increasingly hostile towards her. Some time later, Elizabeth visits the house, hoping to make peace with Emily. When Emily tells her that she is playing hide-and-seek with Charlie, Elizabeth indulges her by pretending to look for Charlie. When she opens the closet, someone bursts out and pushes Elizabeth out a second-story window to her death.
After the police discover her car crashed near David's house, David asks Emily what happened. Emily claims Charlie caused her death by pushing her out her wind and then tells David the location of her body. A terrified David discovers Elizabeth's body in the bathroom in a bathtub full of blood. David asks Emily where Charlie is, and Emily tells him that Charlie has "just left".
David, armed with a knife, goes outside, where he meets the neighbor who has become friends with Emily. David assumes that his neighbor is Charlie and begins to act aggressively. Becoming suspicious that David has killed his own daughter, the neighbor asks to see Emily, but David cuts the neighbor with his knife. The neighbor then calls the police.
Back in the house, David finds that, although he has been in his study many times (listening to his stereo and writing a journal), the boxes were actually never unpacked after the move. With this, David realizes that he has split personality and that Charlie is not imaginary at all, but that in fact "Charlie" is David himself. Whenever "Charlie" would emerge, David was in his study. Charlie was actually in control. David also realizes that under his Charlie personality, he killed his wife and then made it appear to be a suicide. He also fully recalls the events of the New Year's Eve party the night before his wife's death. Immediately after the countdown to midnight, David noticed his wife slip away. He followed her and caught her having sex in a stairwell with another guest. "Charlie" was created as a way for David's rage to destroy his wife, something that the docile David himself was too decent to do. Emily knew the entire time about her father's split personality, but did not tell him to avoid freaking him out.
Once Charlie's identity and horrible deeds are realized to David, he becomes completely consumed by Charlie, leading him to murder the local sheriff, who arrives to investigate the previous altercation. Emily calls Katherine for help.
Katherine arrives and is pushed down the basement stairs by Charlie. Charlie/David, determined to play a hideous game of hide-and-seek with Emily once again, starts counting. Emily dashes and hides. She tricks Charlie and manages to lock herself in her room. As Charlie tries to break in, she climbs out from the window and runs into the cave where she originally met Charlie.
Meanwhile, Katherine takes the gun from the dead sheriff, breaks out of the basement, and finds Charlie looking for Emily in the cave. Charlie pretends to be David and attacks Katherine when she lowers her guard. Katherine begs for David to come out and fight his murderous other personality. Charlie tells Katherine that David no longer exists and that from the minute David discovered the truth about himself, this enabled Charlie to fully take over. Emily emerges from her hiding place, begging Charlie to let Katherine go. Her distraction allows Katherine to shoot Charlie, killing him at last.
Sometime later, Emily is preparing for school in her new life with Katherine. But Emily's drawing of herself with Katherine has two heads, suggesting that due to the trauma of witnessesing what happened to her father, Emily now also suffers from split personality....