Rigellian fever, an extremely deadly plague, strikes the U.S.S. Enterprise crew. Kirk, Spock and McCoy beam down to a supposedly uninhabited planet, Holberg 917-G, in search of the only known antidote, ryetalyn. To their surprise, they encounter Flint and his daughter, Rayna. Not pleased to have visitors, Flint orders his robot to gather and process ryetalyn, while the three officers are entertained by his daughter. Due to the robot contaminating the first batch of antidote, McCoy tells it another must be made. In the meantime, Kirk and Rayna have become attracted to each other, to Flint's jealous objection.
Spock has discovered, to his puzzlement, old masterpieces on modern supplies, i.e. a da Vinci painting done with modern oils on new canvas and an unknown Brahms waltz, written on new paper. Flint explains that he is an immortal, who wandered the Earth for centuries in various personas, including Brahms and da Vinci. He came to this planet to retire in peace and built the "Rayna" android as his companion. He had hoped that her involvement with Kirk would speed up her emotional growth, but now he has become hopelessly jealous. Not understanding such intense emotions, Rayna short-circuits and "dies."
The landing party takes the ryetalyn and returns to the Enterprise. McCoy tells them that Flint, too, will soon perish because what made him immortal was the atmosphere of Earth. Leaving it robbed him of that power.
In a surprisingly compassionate gesture, Spock uses a Vulcan mind touch to erase the painful memories of Rayna from Kirk's mind.