Set in the 24th century, the series follows the adventures of the crew of the Starfleet starship USS Enterprise-D. In this episode, Commander Data (Brent Spiner) aborts an emergency mission and hijacks the Enterprise in response to a homing command from his "father".
A misguided prank between two young brothers exposes one of them to a toxic parasite that cannot be treated aboard the USS Enterprise, but Dr. Crusher (Gates McFadden) is able to stabilize his condition in a controlled environment in Sickbay while the ship sets out for a facility that can cure the boy. As Commander Data (Brent Spiner) escorts the older brother to visit his sibling, he suddenly stops and returns to the bridge, where, unseen by the crew, he triggers an alarm causing the evacuation of the bridge to be ordered. Captain Picard (Patrick Stewart) 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 lock down, 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 of Terlina III, 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 lock down. 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 (Brent Spiner). 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 (Brent Spiner), 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 and 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 dies, 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.
Rick Berman's initial story did not involve Lore. The character was added at Michael Piller's suggestion, who believed the story needed an additional jeopardy element. Piller recalled:
We were standing around going through Rick's story and my feeling was that after reading his first draft that the idea of Data going back to see Dr. Soong and the story of the child who was hurt in the practical joke were not enough elements to hold up the episode. Once Data goes back to see Dr. Soong, it's basically a chat and without some jeopardy or another event to go on I was afraid it was going to be flat. We talked about what we could do and, ultimately, the obvious thing was that we bring Lore back. ..I knew from the moment we came up with it that Brent Spiner in three roles was going to make for an unforgettable episode and I think it was.