The Enterprise travels to the Omicron Theta star system, where Data was found 26 years ago, and from which the colony has disappeared. When they arrive, they find the planet's been stripped completely bare. They then find a hidden cave.

Inside this cave are several laboratories, where Data remembers some of his functions being tested. We discover that he was constructed by the famous roboticist Dr. Noonian Soong, who left Earth after being humiliated by his failure to bring to life his promise of Asimov's positronic brain. Finally, the away team finds, disassembled, a second android, identical to Data!

They beam up with it and both Medical and Engineering get to work assembling it. After the assembly is completed, Picard and Data (with others) await the first signs of consciousness. When Picard asks, "I wonder which of them was constructed first," the other android awakes and says, "He was-but they found him to be imperfect, and I was made to replace him." His name is Lore.

Lore has approximately the same mental and physical abilities as Data, but seems far more human. This quickly proves to be more a danger than a blessing, as we find that Lore can lie. For example, Lore was constructed first, not Data; he was disassembled because the colonists were jealous that he was "perfect." Lore explains to the crew how the colony was destroyed: a crystalline entity which feeds on life appeared and essentially ate the colony up.

Lore's arrogance quickly turns into megalomania. He drugs Data and exchanges places with him, then contacts the crystal and begins to make arrangements to give it the Enterprise, just as he once gave it the colony. Only Wesley is suspicious of the switch; none of the adult crewmembers think "Data" is anything but Data. As the entity arrives, Picard sends "Data" to check on "Lore," harshly reprimanding Wes for his recommendation not to leave the meeting unguarded. Lore uses deception to get Wesley and Riker to leave, then damages Data. Wes suggests one last time that Lore is pretending to be Data and is sent off the bridge, with Beverly coming along to keep an eye on him.

Lore speaks to the entity on the bridge, telling it the ship is powerful. He suggests beaming out something, secretly planning to inform the crystal ahead of time and to leave the ship vulnerable. Wes convinces Bev to check Data's quarters, where they find him injured. He is repaired enough to pursue Lore, and after a quick battle, Wesley beams Lore out into deep space. The entity, no longer having any means to endanger the ship, leaves, and Wesley is sent back to the bridge, reinstated in full.