Star Trek: Requiem for Methuselah

On stardate 5843.7, the crew of the USS Enterprise is struck with a deadly disease known as Rigellian Fever and heads to the remote planet Holberg 917-G, in search of the mineral Ryetalyn to manufacture an antidote. Once there, sensors detect humanoid life despite the reports that the planet is listed as uninhabited.
Captain Kirk, along with his first officer Mr. Spock, and chief medical officer Dr. McCoy, beam down to the planet to investigate and are quickly attacked by a floating sentry robot. The robot is called off by its master, who steps forward and identifies himself as Flint. Flint claims that the landing party is trespassing on private property, and orders them to leave his planet immediately, threatening to kill them if they do not comply.
Kirk, however, will not accept Flint's authority and calls Mr. Scott on the Enterprise to shoot a spread of phaser fire at their position if any harm comes to them. Such an attack would completely vaporize everything in the area. At first, Flint thinks Kirk is bluffing, but he finally backs down and reluctantly talks with his uninvited guests. McCoy informs Flint about the disease that threatens the Enterprise crew and about the urgent need for the minerals on the planet. Flint listens and compares the epidemic to bubonic plague in Constantinople, Earth in the summer of 1334.
Flint allows the landing party two hours to gather the Ryetalyn mineral and offers the services of his sentry robot, "M4", to find and gather the mineral for them. Meanwhile, Flint escorts the landing party back to his home. They are amazed at Flint's impressive collection of Earth artifacts which includes original copies of Shakespeare, a Gutenberg Bible, and lithographs by Terra Nullus of Centaurus VII. Spock is puzzled when his tricorder scans reveal the impressive works are new recreations made with contemporary materials. It is as if the original masters had returned to remake them.
The party is then surprised by the appearance of Flint's beautiful adopted daughter, Rayna, who instantly takes a liking to Spock. Spock is impressed with her incredible knowledge of advanced physics and the two discuss warp field density and its relationship to gravitational dynamics. Flint states that Rayna's parents used to be in his employ, but died in an accident. He has proudly assessed Rayna's knowledge to be the equivalent of 17 university art and science degrees.
Kirk plays billiards with Rayna, then they dance while Spock plays a waltz on the piano. Spock determines the waltz to be an unknown piece written by Johannes Brahms since the work seems to be written in his style and by his own hand. Back in Flint's lab, McCoy analyzes the Ryetalyn gathered by M4 and discovers that it is contaminated with "irilium", rendering it inert and useless.
Meanwhile, Kirk romances Rayna but M4 appears and attacks him. Spock enters just in time and destroys the robot with his phaser. Flint rushes in and Kirk confronts him about the attack. Flint excuses it as a simple misunderstanding, explaining M4 interpreted Kirk's advances toward Rayna as hostile. Kirk forgives the incident and is rather relieved of M4's demise, but is shocked when Flint quickly summons a replacement sentry.
Kirk contacts the Enterprise and asks Lt. Uhura to check out Flint's and Rayna's identities. She finds nothing except that Holberg 917-G was purchased 30 years ago by a private investor named Brack. In the meantime, Spock, using a surreptitious tricorder scan, discovers that Flint is over 6,000 years old.
With the materials almost ready, Rayna comes to Kirk to say goodbye. Kirk is madly in love with her and begs her to come with him. McCoy then informs them that the Ryetalyn is now missing and a search begins. Spock follows the tricorder readings to a hidden chamber where they find other Raynas, who are apparently all androids.
Flint arrives and Kirk demands an explanation of what is going on. Flint confesses that he is immortal, born on Earth in Mesopotamia, in the year 3834 BC. He was first a soldier, and after falling in battle and later recovering, he learned he could live forever. As time went on he lived the lives of famous identities: Alexander the Great, Lazarus, Leonardo DaVinci, Johannes Brahms, King Solomon, Merlin, Methuselah, Reginald Pollack (of the late 20th century), the painter Sten from Marcus II, and many others throughout history. He also says he personally knew Moses, Galileo and Socrates. He explains his purpose for making Rayna was to create a mate who would never grow old, and live forever just as he can.
Horrified, Kirk believes it's time to leave, but Flint refuses to let them go since they have learned his secret. He also claims that Kirk has taught Rayna something he has never been able to: true love. He now wants Kirk to direct Rayna's love toward himself. Kirk refuses to give into Flint's demands and contacts the Enterprise to beam them up and prepare to leave orbit.
Flint then activates a device that teleports the Enterprise to the planet, miniaturized to the size of a desktop model with the crew in a state of suspended animation, as seen by a giant Kirk peering through the viewscreen. Flint is quickly shamed into restoring the ship, but when he realizes Rayna will not turn her love to him, Flint attacks Kirk and a brawl ensues. Rayna tries to stop the fight and her feelings are torn in a logic loop between the two men. This causes the android's circuits to overload and she collapses dead on the floor. Flint and Kirk stop fighting and the two grief-stricken men mourn over Rayna's body.
Both men are devastated, but Flint regains his composure and allows Kirk to leave with the supply of Ryetalyn. Back on the Enterprise McCoy discovers from his readings that Flint is dying. Only the complex fields of Earth were keeping him alive, but his life off world is now aging him normally. Kirk remains distraught over Rayna, affecting his ability to command. Spock uses a Vulcan mind meld and utters the word "forget", presumably causing Kirk to forget Rayna or at least to forget the pain, so that he could return to his duties.