A misguided prank between brothers exposes one of them to a toxic parasite that cannot be treated on the USS Enterprise, but Dr. Crusher is able to stabilize his condition in a controlled environment in Sick Bay while the ship travels to a facility that can cure the boy. As Data escorts the older brother to visit him, Data suddenly stops and returns to the bridge, where, unseen by the crew, he triggers an alarm that forces the bridge to be evacuated. Captain Picard orders Data to transfer the controls to Engineering, but Data instead mimics Picard's voice and locks the command of the ship to the bridge, directing the starship to an unknown planet. The crew discover Data's lockdown, and disable the transporter's site-to-site function to prevent Data from easily moving about the ship. Once the Enterprise is in orbit about the planet, he creates a programmed sequence of force fields to allow him to move from the bridge to the nearest transporter room without being stopped by security, and then beams down to the planet, leaving the Enterprise still under his lockdown. Picard orders his crew to attempt to override any parts of the ship's control, while Dr. Crusher attempts to keep the infected boy stabilized.
Data finds himself in the home of his creator, Dr. Noonien Soong. Soong states he called Data to him using a form of automatic recall, and makes a manual adjustment on Data to return him to normal. Soong tells Data that he is dying, and wishes to bestow an "emotion chip" to him. As they talk, they are joined by Lore, also drawn by the same recall that Data received. Soong is shocked to learn Lore was reassembled, and when Lore attempts to claim the emotion chip as his own, Soong acknowledges that the androids are identical apart from minor variations in programming, but that the emotion chip is still meant for Data alone. With Lore's revelation, Soong decides to rest before implanting the chip, leaving Data and Lore to talk. When he returns, he proceeds to implant the chip but discovers too late that Lore had managed to deactivate Data and switch clothing with him, such that he now possesses the emotion chip. Soong tries to warn Lore the chip is not meant for him, but Lore instead strikes Soong and transports off the planet.
The crew of the Enterprise have found a way to beam down to the planet, and find the dying Soong and the deactivated Data. After Data is reactivated, he cannot recall any of what he did on the Enterprise to lead to this planet, but Soong is able to reveal where Data can find that information as to unlock the ship's controls. Data apologizes to Soong that he will not be able to grieve for his loss, but Soong knows that Data will find a way. After Soong passes away, the Enterprise returns on course to the medical facility. Data observes the brothers at play after forgiving each other for the accident, contemplating his own relationship with Lore.