Stardate 4768.3: Someone attempts to signal the Enterprise and they follow it to the outer edge of the galaxy where they find a planet that has been rendered uninhabitable by some kind of ancient cataclysm. A voice speaks to them out of thin air and identifies itself as Sargon and invites them to visit, speaking of them as its "children."
Kirk decides to resume contact and sends an update to Starfleet, three weeks away. Spock detects an energy source 100 miles within the planet but no lifeforms. Sargon speaks again and asks them to come down and rescue them from oblivion, and assures them he can make sure they arrive safely. Spock detects a breathable atmosphere and Kirk decides to go down with McCoy. When he tells Spock to stay behind, the ship's power goes dead until Kirk agrees to take Spock with them. When they arrive in the transporter room they find Dr. Anne Mulhall waiting for them. She says she was "told" to join the landing party, much as Spock did. Accompanied by two security officers, the landing party enters the transporter chamber but only Kirk, Spock, McCoy, and Mulhall are beamed down when Sargon takes the controls.
Arriving in an underground chamber, Kirk establishes contact with the Enterprise. They then enter a neighboring chamber and find a glowing sphere and within is the mental essence of Sargon. He says over 500,000 years ago they colonized distant planets, possibly including Earth and Vulcan. Sargon says his race suffered a great schism when they came to believe themselves as gods. Kirk asks what Sargon wants and he's enveloped in a glow… then speaks with Kirk's voice as the globe dims. Sargon is pleased with the condition of Kirk's body, although McCoy notes that Kirk's metabolism is greatly accelerated and he'll die if Sargon doesn't leave his body. Sargon says there are two other receptacles, and they require Mulhall and Spock to provide additional bodies so that they can live again.
Sargon/Kirk shows them a room full of containers, only two of which are active. One is his wife Thalassa, and the other is Henoch from the other side. They all united to perpetuate their race as the end came. Sargon explains that they want to borrow their bodies and can provide a serum that will lower the host bodies' metabolisms. He then explains that they need the bodies to build humanoid robots they can permanently occupy. The weakened Sargon then returns to the globe and leaves Kirk in control of his body.
Kirk calls together a meeting of the senior officers and Mulhall, and Scotty and McCoy both object. Once Sargon and the others have mechanical bodies, they can pass on their knowledge, offering warp drives the size of walnuts. Kirk makes an inspiring speech and convinces them to agree with his decision. They do so and beam up the three spheres to Sickbay. The transposition takes place and Sargon and Thalassa are reunited, while Henoch is impressed with the improved Vulcan body. Kirk and Mulhall's bodies almost immediately show signs of weakness, but Spock's body is more accustomed to the higher metabolic rate. Henoch will make a metabolic reduction serum while Sargon and Thalassa return to their globes. Henoch asks for Nurse Chapel's assistance and leaves for the lab.
Henoch creates three different serums and gives them to Chapel to administer. When she notices that the one for Sargon/Kirk is different and will cause his death, Henoch wipes her memory.
Sargon and Thalassa work on the humanoid robots and reminisce about their lives together, while Henoch on in amusement then taunts Thalassa with the robot body she'll enter. Sargon shows signs of weakness but assures Thalassa he's okay. McCoy checks with Chapel who assures him everything is fine.
Thalassa is preparing the androids when a skeptical Scotty comes in. Henoch interrupts them then after Scotty leaves, he taunts Thalassa again with the idea of imprisonment in a robot body when there's another option that Sargon refuses to consider. She admits she's beginning to hate the idea of occupying an artificial body and stalks off. She goes to see a weakened Sargon who dismisses her concerns and refuses to hear of their occupying their chosen bodies permanently. She kisses him and he collapses: McCoy arrives and after a brief attempt to revive him, pronounces him dead.
McCoy takes Kirk's body to Sickbay and keeps it alive on life support. Thalassa offers him Kirk, restored, in return for the chance to keep her body. When McCoy refuses her, she mentally tortures him but stops when she realizes what she has become, what Sargon warned against. Sargon then speaks out and explains he has powers Henoch is unaware of. Sargon has placed his consciousness into the Enterprise Thalassa calls in Chapel, still under Henoch's control. As soon as McCoy leaves, the ship shakes and he returns to find all three of the spheres destroyed. Chapel walks by still in a trance, while McCoy finds that Kirk and Mulhall are restored to their bodies. Spock's consciousness is seemingly destroyed and Kirk orders McCoy to prepare a hypo of Vulcan body so they can kill his body.
Henoch/Spock is on the bridge mentally torturing Uhura while Chapel stands by. Kirk, Mulhall, and McCoy arrive on the bridge and Henoch causes Kirk and Mulhall to collapse in agony. McCoy tries to inject him but Henoch stops him and tells Chapel to inject McCoy with the poison. Chapel begins to… then injects Henoch/Spock instead. He prepare to transfer to another body but he realizes Sargon is still alive and stops him from transferring. Henoch's consciousness is destroyed and Kirk believes Spock is dead as well, but Sargon reveals Spock is safe. Chapel collapses and Spock gets up, while Sargon explains there was no poison. McCoy had to believe it was real to fool Henoch, but it only caused unconsciousness. Spock explains they kept his consciousness inside Chapel.
Sargon says that he and Thalassa must now depart into oblivion as the temptation is too great. He asks Kirk and Mulhall to let them share their bodies one last time. The two agree then Sargon and Thalassa kiss. They leave, leaving Kirk and Mulhall in an embarrassed clinch.