John Murdoch (Rufus Sewell) wakes in a hotel bathtub, suffering from what seems to be amnesia. As he stumbles into his hotel room, he receives a call from Dr. Daniel Schreber (Kiefer Sutherland), who urges him to flee the hotel from a group of men called The Strangers. During the telephone conversation, John discovers the corpse of a brutalised, ritualistically murdered woman, along with a bloody knife. Murdoch flees the scene, just as the Strangers arrive at the room. Eventually he uncovers his real name, and tracks down his wife Emma (Jennifer Connelly). He is also sought for a series of murders, which he cannot remember, by police inspector Frank Bumstead (William Hurt). Murdoch stays on the move in the city, which experiences perpetual night. He sees people fall comatose at the stroke of midnight, and he is pursued by The Strangers. In the chase, he discovers that he has psychokinetic powers like the Strangers, which he uses to escape from them.
Murdoch questions the dark urban environment and discovers through clues and interviews with his family that he was originally from a coastal town called Shell Beach. Attempts at finding a way out of the city to Shell Beach are hindered by lack of reliable information. Meanwhile, the Strangers, disturbed by the presence of a human who retains their powers (which they refer to as tuning) inject one of their men, Mr. Hand (Richard O'Brien) with Murdoch's lost memories, in an attempt to track down Murdoch.
Constantly on the run, Murdoch witnesses the Strangers altering the city's landscape and people's identities during the still period at midnight, during which time everyone is unconscious. Murdoch eventually meets Bumstead, who recognizes Murdoch's innocence and has his own questions about the nature of the dark city. They find and confront Dr. Schreber, who explains that the Strangers are endangered alien parasites with a collective consciousness who are experimenting on humans to analyze the nature versus nurture concept of their human hosts in order to survive. Schreber reveals Murdoch as an anomaly who inadvertently woke up during the midnight process with the ability to tune.
The three men embark to find Shell Beach, which ultimately exists only as a billboard at the edge of the city. Frustrated, Murdoch tears through the wall, revealing a hole into deep space. The men are confronted by the Strangers, including Mr. Hand, who holds Emma hostage. In the ensuing fight, Bumstead falls through the hole into space, revealing the city as an enormous space habitat surrounded by a force field.
The Strangers bring Murdoch to their home beneath the city and force Dr. Schreber to imprint Murdoch with their collective memory. Schreber, having worked for the Strangers, betrays them by instead inserting memories in Murdoch that train his tuning abilities. Murdoch awakens, fully realizing his abilities, breaks free and battles with the Strangers, defeating the leader Mr. Book (Ian Richardson) in a battle high above the city. Utilizing his newfound powers, Murdoch begins reshaping the city, returning the sun, flooding the areas surrounding the city with water and forming mountains and beaches, creating the actual Shell Beach.
The Strangers who survived Mr. Book's death retreat from the sunlight to die underground. On his way to Shell Beach, Murdoch encounters Mr. Hand and informs him that the Strangers have been searching in the wrong place, the head, to understand humanity. Murdoch opens the door leading out of the city, and steps into sunlight for the first time. Beyond him is a dock, where he finds Emma, now with new memories and a new identity as Anna, with no recollection of Murdoch. They reintroduce and walk to Shell Beach, beginning their relationship anew.