The Enterprise is exploring a planet on the outer edges of the galaxy. The landing party, Kirk, Spock, McCoy, and Sulu, find the remains of an advanced civilization and a still-active power source. As they trace it to a particular building, Sulu notices a small mobile plant and picks it up. It stings him with a thorn and he drops it.
Inside the building, the landing party discovers a large section of it protected by a force field. McCoy detects an immense life form reading on his tricorder. Before they can check it out, Sulu collapses in pain. McCoy checks him and determines that he's dying of poison from the mobile plant. He has less than a minute left and McCoy has no idea how to treat him.
Four plant-like creatures, the Phylosians, suddenly appear and offer their help. Kirk accepts and the leader, Agmar, administers an antidote to Sulu that quickly cures him. McCoy is impressed and wonders how they knew their antidote would work on a humanoid life form. Agmar explains that they've had contact with humanoids in the past and detected the Enterprise's presence on their sensors, but have a fear of aliens and chose not to reveal themselves.
Kirk notes that Agmar and the three others seem to be the only inhabitants of the planet. Agmar takes them to an underground chamber where the corpses of thousands of larger, more advanced Phylosians are stored. Agmar explains that they are his preceding generation. A human came among them, bringing a disease that wiped out all but a few of them such as Agmar. The human did what he could to cure the staphylococcus strain that he brought with him but had no success.
Winged swoopers fly into the chamber and attack the landing party. Kirk and the others try to fire their phasers but Agmar informs them a weapon deactivator is in place. The swoopers grab Kirk, Sulu, and McCoy and fly away with Spock. Agmar informs them that the "Master" has long sought someone with a perfect blend of physical and mental traits and Spock is the one they need to bring peace to the galaxy. A giant humanoid figure enters and introduces himself as Dr. Stavos Keniclius 5. He tells Kirk that Spock is his now and the landing party must leave. Kirk has no choice but to depart.
Back on board, Sulu determines that the underground levels of the city are shielded against the scanners. They try to fire the ship's phasers on the city but learn the weapon deactivator works against the Enterprise weapons as well. Kirk checks in with Scotty, who is working on a special mechanical device. McCoy arrives and tells them that he's managed to duplicate his grandfather's old gardening recipe. Uhura checks the database and brings up the files on Keniclius. He was a scientist during the Eugenics Wars that proposed the use of cloning to create a perfect race. He was exiled for his theories and then disappeared. Since then there have been persistent rumors of a scientist searching the galaxy for a perfect specimen. That was 250 years ago, but Kirk concludes that Keniclius duplicated himself five times over, hence the title of Keniclius 5.
As Kirk, Sulu, and McCoy prepare to beam down to the planet, Scotty gives them pouches containing the equipment he constructed. The captain orders Scotty to take the ship out of orbit so that the Phylosians would assume they left. Back on the planet, the landing party enters an enormous hangar filled with Phylosian ships, and McCoy figures the plague wiped out the crews before they could launch. They find and capture Agmar, who insists that Spock must stay with them to carry on their work. The Phylosians had planned to launch a galactic peacekeeping force when the plague struck, rendering them sterile. However, Agmar readily agrees to lead them to their comrade. Kirk has no choice but to let him lead them to the first officer.
Agmar takes them on a hover platform into the depths of the city. Swoopers move in and Agmar shuts off the lights. They need light to use Scotty's equipment and run to the nearest illumination. They find Spock in a vast chamber, hooked up to a machine that McCoy confirms is draining his mental energies. Keniclius arrives and tells them that Spock must die so that his mental essence can be transferred into a giant clone body: Spock 2.
The swoopers come after the landing party, who don rebreathers and use Scotty's devices: mechanical gas sprayers loaded with weed killer. The creatures are killed while Spock 2 and Keniclius retreat before the toxic fumes. The shielding prevents them from contacting the ship for help. McCoy examines the original Spock and warns that he only has minutes to live and his mind is already gone. Keniclius returns and explains that while he can clone an individual, he can't duplicate their mind, their knowledge. Kirk tries to leave with Spock but a mute Spock 2 blocks his way. The giant Vulcan seems confused and McCoy deduces that he is still trying to assimilate all of the information from the original's mind.
Aboard the Enterprise, Uhura has learned additional information about Keniclius and Scotty orders all of the ship's energy focused into a single communication beam to penetrate the Phylosian shielding. On Phylos, Kirk asks Spock 2 to explain the logic of killing the original to create a duplicate. Scotty's signal gets through but Kirk gambles and throws his communicator to Spock 2. He accepts the ship's transmission and Uhura tells them that Keniclius' later writings talk of using his perfect race as a galactic peacekeeping force to bring all of the warring factions together. The information passed on, Uhura cuts off the signal just before they burn out the dilithium crystals.
Kirk tells Keniclius that the galaxy as already achieved peace and they did it on their own. The Phylosians arrive and explain that they shared Keniclius' vision of a galactic peace and were preparing to launch their fleet when Keniclius arrived and brought the plague with them. Despite Kirk's protestations, Keniclius stubbornly refuses to save the original Spock. Kirk challenges Spock 2, asking him if there is any logic to imposing peace in contradiction of IDIC. Spock 2 agrees with him. An angry Keniclius smashes the mind transference device maintaining the original Spock's life. Agmar charges the landing party and Sulu uses a judo throw on him. Kirk runs to his friend but Spock 2 stops him and offers a more constructive approach. He mind melds with the original and restores his mental facilities. Spock 2 then says that he'll stay on Phylos and make sure that Keniclius doesn't create more giant Spocks. When the eugenicist wonders what he can do now that his vision has been fulfilled, Spock suggests that he put his knowledge to use by helping the Phylosians recultivate their race. Keniclius agrees to help the Phylosians who took him in and Kirk assures him that he'll notify the Federation and they'll prove whatever help is necessary to assure that Phylos joins the Federation.