In the town of Castle Rock, Maine, Johnny Smith (Christopher Walken), a young schoolteacher, is in love with his colleague Sarah Bracknell. He is involved in a serious car accident that sends him into a coma. He awakes under the care of neurologist Dr. Sam Weizak and finds that five years have passed and that his girlfriend has since married and had a child. Johnny also discovers that he has the ability to learn a person's secrets (past, present, future) through making physical contact with them. As he touches a nurse's hand, he sees her daughter trapped in a fire and also realizes Dr. Weizak's mother, long thought dead from the war, is still alive. As news of his "gift" spreads, he is asked by the nearby sheriff (Tom Skerrit) for help with a series of killings but declines. Sarah visits him with her infant son and the two wind up making love.
Johnny then agrees to help the sheriff and through a vision realizes it's his own deputy that is committing the murders. Before they can arrest him, the deputy gets away and commits suicide. Johnny is then shot and injured by the man's mother. Disillusioned, Johnny moves away and attempts to live a more isolated life, taking on tutoring jobs and working from home.
After seeing a vision of the boy he is tutoring falling through the ice during a hockey game, Johnny warns the boy's father and the boy avoids the tragedy, although two other boys are killed. Johnny then realizes his visions are real, meaning that he can actually change the future.
Later, Johnny discovers through a handshake that a Senatorial Candidate whom Sarah is volunteering for, Greg Stillson (Martin Sheen), will become President, and through the handshake sees Stillson ordering a nuclear strike against Russia, thus presumably bringing on a nuclear holocaust. After clearing his mind regarding this by talking hypothetically about it to his doctor, Johnny feels it to be his duty to assassinate Stillson. Johnny attempts to shoot Stillson at a church rally, but misses and is shot by Stillson's security detail, while Stillson grabs Sarah's baby and holds him up in the air as a human shield; this act is photographed. Johnny is confronted by an angered Stillson; he grabs his hand and foresees Stillson committing suicide due to the destruction of his reputation after his cowardly act is revealed. Johnny then says to Stillson "It's over. You're finished." A satisfied Johnny then dies with Sarah by his side.