On the planet M3X-387, Sheppard's team finds a crystal emitting low-level energy readings. The glowing crystal mesmerizes Sheppard, who touches it and receives a shock. The crystal goes dark, and the team hurries home so Dr. Keller can make sure that Sheppard's okay. He seems to be.
That night, however, Teyla dreams that Sheppard is attacking her. Dr. Kate Heightmeyer, Atlantis's psychologist, kindly warns her not to put too much stock in dreams, but Teyla is afraid to sleep. Only after Keller gives her a sedative does she feel better. The next night, Keller also has a nightmare in which Sheppard's the bad guy. Then Ronon, too, dreams that Sheppard wants to kill him. Based on these experiences, Keller and Col. Carter agree that Sheppard's brush with the crystal wasn't as harmless as it seemed. As if either woman needed more convincing, a sleepwalking Maj. Lorne suddenly pulls a gun on Sheppard, convinced that Sheppard is dangerous.
After Ronon stuns Lorne, the team constructs a working theory: a sociopathic energy being from the crystal has stolen Sheppard's image and is jumping from person to person, generating terrifying dreams, perhaps because it feeds on fear. McKay and Zelenka return to M3X-387, where they collect both the inert crystal that Sheppard touched and a new one that's still glowing. By studying both, they pinpoint an energy signature that will allow them to track the entity. Tracking it, however, may prove easier than stopping it: although they're able to keep their new specimen trapped in a non-conductive container, the old specimen is traveling the city at will through power conduits.
That night, Dr. Heightmeyer also has a nightmare. The next morning, the team is grief-stricken to discover that Heightmeyer really has died, killed by her dream. The entity is deadly - and soon it moves on to a new host: McKay.
With the freaked-out scientist locked in a non-conductive isolation room, demanding coffee so he won't fall asleep and die, his friends decide that they must try to communicate with the entity. Keller sedates McKay, allowing Sheppard to use alien mind-linking technology (obtained by Carter during her years on SG-1) to enter McKay's dream world.
He finds himself in a rowboat with McKay, far out in the ocean, being menaced by a whale. In the back of the boat sits the entity - which looks just like Sheppard. It taunts McKay, threatening him with death. Despite the real Sheppard's best efforts, McKay gives up and the whale swallows the boat. In the isolation room, McKay flatlines. Sheppard's nightmarish duplicate is about to claim another victim.