The U.S.S. Enterprise arrives in orbit around Exo III, to search for exobiologist Dr. Roger Korby. When Kirk asks Spock if Korby could possibly still be alive, Spock glances at Christine, then quietly shuts off his monitor. Christine Chapel, McCoy's chief nurse, is Korby's fianc?e. Chapel had signed on with the U.S.S. Enterprise in the hope of finding him. Korby is known as the "Pasteur of archeological medicine."
At Dr. Korby's request, only Kirk and a very excited Christine Chapel beam down to the planet. They find the doctor living in an underground cavern built by what is known as "The Old Ones," the extinct natives of Exo III. He tells them that he discovered the caverns while suffering from severe frostbite, five years before.
Using equipment left behind by these now-dead beings, Korby has learned how to construct androids who look and act like humans. His android companions, Ruk and Andrea, amaze Kirk and Chapel with their realness. Although, Korby explains, Ruk existed long before he arrived — a product of "The Old Ones."
Christine recognizes Dr. Brown, Korby's aide, but is mystified by his failure to recognize her. The reason for his behavior becomes clear when they discover that he, too, is a sophisticated android. Korby's plan is to slowly replace key people in the Federation with androids, integrating the machines into other worlds.
Taking Kirk prisoner, Korby creates a perfect duplicate of the Captain, which fools even Nurse Chapel. During the duplication process, however, Kirk plants false memories and ideas in his double's brain which makes Spock realize that something is very wrong. Korby, convinced that his android will fool the U.S.S. Enterprise crew and allow him to take over the starship, has the double beamed aboard. The false Kirk is to look over their proposed route and pick a likely planet on which to begin colonization.
Spock immediately becomes suspicious of his captain until finally, after spewing an ethnic slur at the first officer, Spock is certain that this is not Captain Kirk. He orders a landing party to meet him in the transporter room after the Captain has beamed down to the planet. Meanwhile, on Exo III, Christine Chapel realizes that somehow Roger Korby has changed; he's no longer the wonderful man she'd fallen in love with. He's become somehow distant and unfeeling ... though he obviously still has a great fondness for his fiancee.
Separated from Christine, Kirk is being guarded by Ruk. The Captain convinces the hulking android that Korby is a threat to his continued existence and must be destroyed. Ruk attacks Korby and is eliminated. It is discovered, to Christine's horror, that Korby has housed his essence inside an android body. Kirk convinces the doctor that he's become more machine than human. In front of his horrified fianc?e, Korby grabs Andrea and fires a phaser blast that kills them both. Spock arrives with a landing party to find only Kirk and Christine remaining. Chapel announces that she would like to stay with the U.S.S. Enterprise to complete her tour.