The Enterprise is in the grip of a deadly epidemic: Rigellian fever. Kirk, Spock, and McCoy beam down to Holberg 917-G to gather the mineral ryetalyn (amusingly pronounced Ritalin), necessary to create an antidote. On the planet's surface, they encounter Flint, who says he owns the planet: his personal retreat from the human race.
Flint introduces his young ward Rayna to the party, and while McCoy and Flint's sentry robot M4 process the ryetalyn, Kirk gets up close and personal to the beauty. It was at this point that I guessed that Rayna was an android, created by Flint as a companion (ie. Sex robot), and I wasn't far wrong. Flint is allowing Kirk and Rayna to get smoochy in order to bring her emotions alive, so that she can return her creator's affections.
What I didn't guess is that Flint is immortal, having lived for 6000 years, during which time he had gone by many names, including Lazarus, Alexander the Great, Leonardo Da Vinci and Johannes Brahms: this combination of the predictable and the unexpected proves very entertaining, with mystery, sex, a miniature Enterprise, and a fistfight, and a sad ending that sees Rayna's conflicting feelings for Kirk and Flint causing her to shut down.
It's not perfect, Kirk's horndog behaviour seeming extremely inappropriate given the seriousness of the epidemic currently ravaging his crew, but it's still a far more enjoyable effort than the last few episodes, proving there's still some life in the series yet (or was that it?).