The Enterprise-D discovers a rogue comet that appears to be over eighty-seven million years old, and initiate a deep sensor scan of it. The crew use a weapon blast to remove the icy outer layers and finds that an immense structure is inside the comet, and has been using the Enterprise scans as a carrier wave to send information back to the ship; this has caused the appearances of strange symbols to appear on the ship's computer and the creation of artifacts throughout the ship by the replicator systems. The effects begin to become more pronounced, and have a significant effect on Data, who starts to exhibit multiple personalities. Though initially they continue to scan the structure hoping to determine how to reverse or stop the changes, they find their attempts to destroy the object are impeded by the changes. Captain Picard determines that they need to understand the meanings of the artifacts, and talks to the various personalities that Data exhibits to learn more.
Through Data, Picard learns that a being called Masaka is waking, and that the only one that can control her is one called Korgano. One of Data's personalities states that Masaka will only appear once her temple has been built, and provides Picard with a pictogram that can create that temple. Inside the temple, they find the symbols that refer to Masaka and Korgano. Data shortly arrives later, wearing a mask he had created earlier with Masaka's symbol on it, and refers to himself as Masaka. Picard has the crew search the database from the structure to recreate a mask representing Korgano, and Picard wears it to confront Data. Picard convinces the Masaka personality to sleep so that she and Korgano can continue their "hunt" another day. With the Masaka asleep, all the changes aboard the Enterprise are reverted, and Data finds himself back to normal. Picard comments that Data, briefly, contained the consciousnesses of an entire civilization, something that "transcends the human condition."