The team are investigating a jungle planet, when they stumble upon a crystal growing on the side of a tree. Overcome with a sudden urge to touch the crystal, Sheppard is blown backwards, and the crystal's light goes out. The team then returns to Atlantis, and Teyla stays with Sheppard as Dr. Keller clears him.
Later on, Teyla is asleep, and she begins having a nightmare, all of a sudden Sheppard appears in the nightmare as a part-Wraith, similar to what he was when he was infected by Elia. He begins to feed on her and she wakes up screaming. She talks to Dr. Heightmeyer about the nightmare, and says she now feels uncomfortable about being around Sheppard.
Teyla tells Ronon and McKay about the dream while eating dinner, but when Sheppard shows up she leaves. McKay and Ronon tell her about the bad dream, and Sheppard says he can't control what she dreams about. McKay then goes on to tell them about how his father read him Moby Dick when he was seven, and how he still has nightmares about it.
Later on, Dr. Keller has a nightmare. In the nightmare she is called in for a medical emergency, and Sheppard has brought Teyla in because she was complaining of stomach pains. Dr. Keller begins to check on her, when suddenly a creature burst out of her stomach, and Teyla is dead. Meanwhile Sheppard looks at Dr. Keller in amazement and acts like it was the coolest thing in the world.
Dr. Keller wakes up, and she heads down to the infirmary to get something to help her sleep, when Ronon and Sheppard show up. They had been sparring, and Sheppard had gotten in a lucky shot. Sheppard leaves while Dr. Keller begins to stitch up Ronon's injury. While she is stitching his wound, he falls asleep and has a nightmare. In the nightmare Atlantis is empty, and then suddenly he is in the wounds and his knocked out by Sheppard. When he comes to in the dream, Sheppard is over him, burying him alive.
Ronon wakes up, and the next morning, Teyla, Ronon, Dr. Keller share their dream experiences, with Sheppard as the bad guy. McKay had yet to have a bad dream involving Sheppard, but he goes on to say he has one every night, and most times he is eaten by a whale.
Dr. Keller expresses her concerns to Carter, but they are interrupted with a security call. Lorne is holding Sheppard at gun point saying he is a replicator. Lorne is sleepwalking, and had also had a nightmare. Shortly after, Dr. Heightmeyer has a nightmare involving Sheppard, and in the nightmare she dies because the evil Sheppard prevented Teyla from saving her. Dr. Keller receives a call from Teyla, and they learn Dr. Heightmeyer really is dead.
Carter believes the crystal has something to do with the dreams, so the team goes back to retrieve another crystal with the entity still inside. While Zelenka and McKay are studying the crystal Dr. Keller has the same urge as Sheppard did to touch the crystal, but Zelenka and McKay stop her.
Later, Zelenka figures out how to find which person the entity is in, and he learns it is in McKay. Carter and Sheppard come up with the idea to enter McKay's dream to help him with the entity, and Sheppard is the one to enter McKay's dream.
McKay dreams he is on a little boat miles away from Atlantis, and he is all alone, and a big whale is circling the boat. The Evil Sheppard appears on the boat, saying McKay should just give up, then the good Sheppard appears as well, and he encourages McKay and helps him row. Sheppard tells McKay the dream isn't as bad as he led him to believe. McKay points behind and says "Oh yeah? What about that?" There is a clown sitting in the seat behind them, and Sheppard states how much he hates clowns. The Evil Sheppard continues to taunt McKay, and Good Sheppard tells him the evil Sheppard can't do anything to him. The Evil Sheppard says he can, and a whale swallows the boat.
Sheppard wakes up, and sees McKay on a table nearby, and he has gone into cardiac arrest. He's dead. Sheppard walks down a corridor and he is confronted by Teyla, Ronon, Carter, and Dr. Keller. They blame him for McKay's death. Sheppard sees the Evil Sheppard standing nearby, and he tackles him through a wall.
Dr. Keller revives McKay, and when he asks about the entity, Zelenka states it is now in Sheppard.
Sheppard and the Evil Sheppard face off in the gateroom. The evil Sheppard says the only thing Sheppard is afraid of is failing his friends, and they begin to fight, with the Evil Sheppard dealing out the better of the blows.
In the real world, Sheppard is still asleep, and his pulse is dangerously high, McKay demands to be sent into Sheppard's dream to help him.
Despite his best, Sheppard is being badly beaten by the Evil Sheppard. The Evil Sheppard has beaten him down, and he says he is responsible for Heightmeyer and McKay's deaths. Suddenly McKay appears behind the Evil Sheppard, and the Evil Sheppard pushed McKay back up against a wall.
The Evil Sheppard says McKay can't win, but McKay says the entity is vulnerable to electric shock. The Evil Sheppard is hit by electricity as Dr. Keller shocks Sheppard in the real world. Taking advantage of the moment the good Sheppard hurls the Evil Sheppard through the gate and back into the crystal.
McKay and Sheppard make sure they are both the real themes. McKay then comments that he expected more hot girls in Sheppard's dreams.
The team returns the crystals back to the planet, and as the do thousands of crystals come to life around. McKay suggests they leave, and Sheppard quickly agrees.
Back on Atlantis Sheppard is sitting up late, when Teyla joins him. They couldn't sleep. Soon McKay, then, Ronon, and Dr. Keller and Carter join them, as the screen fades to black.