Kirk, Spock, and McCoy beam down to the second planet in the Minarian star system, before the star goes nova. They are assigned to recover the two Federation scientists assigned to a research base to monitor the nova. They enter the research station but Scotty notifies them they have to leave to avoid upcoming flares: the atmosphere of the planet will protect the landing party. Spock finds a recording tape and they watch as the two scientists, Ozaba and Linke are talking when a high-pitched noise echoes through the station. The two scientists wince in pain and then disappear. The landing party hears the same noise and Kirk is unable to pinpoint it. One at a time they disappear, Kirk last as he stumbles on the stairs and cuts his forehead.
The trio wake in an unlit chamber with spot lighting. Spock determines they were beamed there by a transporter and locates one life form: humanoid but non-human. They approach and find a female, unconscious. Spock determines she couldn't have evolved on that planet and they quickly realize that the woman is a natural mute with no telepathic abilities. McCoy suggests they call her "Gem." They're interrupted when two robed aliens appear, Lal and Thann. They know who the landing party is and explain that they are Vians. When Kirk tries to intervene, they first knock him back with a blast from a handheld unit, then surround all three men in a force field. They examine Gem, seemingly satisfied, then teleport away and drop the force field.
Spock scans for an entrance while Gem notices Kirk's head injury. She concentrates and takes on the injury, removing it from the captain. After a few moments she then heals her own wound as well. McCoy explains that Gem is an empath and can take on the physical and emotional reactions of those near her. Spock returns to indicate he has detected a number of pieces of equipment that he didn't find before. They take Gem with them and go to see the equipment. They also find Linke and Ozaba, dead and grotesquely twisted and placed in glass tubes. They also find three other tubes, labeled "Kirk," "Spock," and "McCoy."
One of the Vians, Lal, appears and notes that the two scientists' own imperfections killed them. He notes that time is short and Kirk distracts him while Spock renders the Vian unconscious. They take his hand unit and Spock finds a passage to the surface. As they depart, Lal stands up, unharmed, and Tharn arrives: all seems to be going according to their plan.
The landing party gets to the surface where the weather has picked up due to the solar flare. Kirk tries to contact the ship without success and they head for the research station. They spot Scotty and two security guards, but Gem falls behind and Kirk stops to help her. He sees Lal and Tharn and sends Gem on ahead, then attacks them. They render him immobile and talk about his will to survive. Gem catches up to McCoy and Spock, who have discovered that the Enterprise rescue party is a mirage. They return to find Kirk, and the Vians inform them that one specimen will be sufficient: the captain. The Vians say that they have no interest in the others and Kirk sends them on ahead despite their objections. However, the Vians teleport them away and then teleport Kirk as well.
Aboard the Enterprise, Scotty determines they have at least 17 more hours until they can enter orbit.
The Vians torture Kirk while Gem is forced to look on. They inform him that they need no knowledge from him but need to him reveal his courage and strength of will. After further torture, they teleport the captain and Gem back to the others. Spock and McCoy are contained in another force field while Gem hesitantly approaches Kirk, takes his hands, and starts to take on his injuries before curing them on herself. She collapses and the others are freed. McCoy notes that the process did weaken Gem and McCoy notes her own instinct for self-preservation would stop her from dying. He confirms that Kirk was suffering from "the bends" due to decompression. Spock has determined that an energy transfer point appears, linked to the Vian device they still have. He concludes he might be able to get it to function for them.
The Vians arrive and inform Kirk that they need one of the others to cooperate in their experiments. Kirk must decide, and they note there is an 87% that McCoy, will die, but Spock has a 93% chance of going insane. After they leave, Spock works to get the hand device working and leaves notes for the others to complete the work. Kirk notes he'll be the one to make the decision if it becomes necessary. Weakened, he collapses and McCoy renders him unconscious with a sedative. Spock is satisfied, since it allows him to make the decision and he'll choose himself for the Vians' experiment. As Spock tries to complete his work, Gem touches him and senses his emotions. McCoy injects Spock with a sedative as well. The Vians arrive and McCoy has Gem wait as he goes with their captors. They apologetically begin torturing him as McCoy is forced to look at his own glass containment tube.
Kirk and Spock wake up and neither are thrilled by the doctor's actions. Spock determines that the device is attuned to its owner and activated by mental commands. He warns that it will only fit one pattern and he adjusts it to himself. Kirk wonders why the Vians let them keep it. Spock concludes the Vians want them to escape and leave McCoy behind. Kirk tries to determine Gem's part in the entire situation. Spock completes the adjustments but warns it will only allow them one trip. Rather then beam to the Enterprise, Kirk has Spock take them to McCoy. They arrive and find him hanging from the ceiling, all but dead.
They get him down but Spock warns that he is mortally injured and all they can do is make him comfortable. Kirk wonders if Gem can save him but Spock notes that it could weaken her to the point of death as well. They try to encourage her to help to stabilize him but the Vians arrive and encase Kirk and Spock in a force field. They explain that no interference is permitted and Gem must save McCoy on her own. They are aware that the system will be destroyed by the nova. The Vians have the power to save the inhabitants of only one planet, and they must make sure Gem's people are worthy of survival. Gem has empathically learned the concepts of compassion and survival, but now they must determine if she has learned the lessons.
Gem approaches McCoy and starts to take on his injuries. However, her instinct for self-preservation kicks in and she backs away, frightened. The Vians consider the failure of their experiment but refuse to heal McCoy with their own devices. McCoy tries to hold her off, refusing to trade her life for his. Spock realizes the force field is feeding on their emotions to power itself. He suppresses all emotion and breaches the field, and disarms the Vians. They still refuse to heal McCoy but Spock insists she has demonstrated suitable self-sacrifice. Kirk gives them back their devices and offers his own life and the others. The Vians have lost their own compassion or the ability to understand what it is they're trying to teach Gem. Chagrined, the Vians heal McCoy, then depart with Gem to save her people.
Back aboard the Enterprise, Spock notes that the Vians engineered the entire thing while Scotty talks of the fable of the pearl of great price, who sold everything he had to obtain it. McCoy notes that for all the Vians' scientific knowledge, it was human emotion they valued the most. They suggest that Spock might pass the information on to the Vulcans, and he promises he'll give it all the consideration it's due.