At midnight, all inhabitants in the city fall into a deep sleep. However, a man without a memory wakes up suddenly in a hotel room. Looking for signs of his identity, he finds a postcard of Shell Beach. The telephone rings and the caller tells the man to flee. The man finds the naked, mutilated corpse of a woman in the room. He's pursued by strangers wearing black but he gets away. The hotel clerk tells the man, Murdoch, that his wallet was found at an Automat.
Nightclub singer Emma Murdoch is summoned to meet with psychiatrist Dr. Schreber, the caller on the telephone, about her missing husband John. Schreber claims that John is his patient and may have suffered a violent, psychotic break.
At the Automat, John discovers he has the power to retrieve his wallet simply by thinking about it. He is stopped by two cops looking for a serial killer who murders prostitutes, but is rescued by May, a prostitute herself. At her apartment, he runs away from her. Attracted to a billboard of Shell Beach, he finds newspaper clippings in his coat about the serial killer. The Strangers from the hotel catch up with him and try to kill him, but John kills some of them.
Emma goes to the police station to file a missing person report and finds that Inspector Bumstead has identified John as the prime suspect in the serial killings. John comes home to Emma and claims he isn't the killer. Emma asks him to visit Schreber. Instead, John tails Schreber and finds out that Schreber is working for the Strangers by switching memories between people. As all city dwellers become unconscious at midnight, Schreber injects people with their new memories and identities. They also create and destroy matter--new buildings rise out of the earth while old ones are swallowed up by it--by thinking in conjunction with an underground machine. Finding their experiments disrupted by John's power, the Strangers search for him.
John visits his uncle Karl (the sender of the Shell Beach postcard) and becomes convinced that his identity is fake. Karl telephones Emma about John's location and apparent mental delusions, but John escapes before she and Bumstead arrive. He's pursued by the Strangers again.
Emma and Bumstead save John from the Strangers. Bumstead tries to interrogate John, but John asks him why it's always night in the city. The Strangers arrive at the police station but John and a convinced Bumstead escape. The Strangers kidnap Emma while John and Bumstead kidnap Schreber and force him to take them to Shell Beach. Schreber explains that all the city dwellers have been kidnapped by the Strangers, a dying alien race. The Strangers mix and match memories among the humans to find the individual soul that they think will save them.
Shell Beach turns out to be a mere billboard on a brick wall. The city is in fact part of a star ship. In a struggle with the Strangers, Bumstead is blown out into the stars. Threatening to kill Emma, the Strangers force John to surrender to them. They force Schreber to imprint him, but the doctor imprints John with the knowledge to destroy the Strangers by controlling their underground machine that powers the city.
In a fierce battle, John frees Schreber and kills the Strangers. By taking control of their machine, John creates the sea, the sun and Shell Beach. The city inhabitants awake. Emma has been given a new identity and name of Anna, but John finds her and they leave together for Shell Beach.