The Enterprise is heading to the Federation planet Ardana to pick up zenite, the only known source of a cure for a botanical plague. They arrive in orbit and Kirk is informed they should go to the Cloud City of Stratos. With time running out, Kirk and Spock ignore the invitation and beam down directly to the mines to get the zenite. Spock notes that the Stratos society claims to have eliminated all forms of violence and are dedicated to art and culture. The two officers go to the main entrance but several of the miners, the Troglytes, lasso them.
The Troglyte leader, Vanna, tries to take them away over Kirk's objections and the officers attack them. The men subdue the Troglytes and Plasus, the high advisor of Stratos arrives with two security guards. They stun one Troglyte and the others escape and Plasus apologizes. He informs them that the Disruptors, a small group of Troglyte malcontents, are holding the zenite. Plasus believes the Disruptors wanted to capture Kirk and Spock and use them as hostages, and invites Kirk and Spock to come to Stratos.
They transport to the sky city and meet Plasus' daughter Droxine. She's intrigued by Spock. Plasus shows them some of Stratos' art and finds one statue marred by a mining tool. Kirk insists on knowing about anything that might affect the recovery of the zenite. Plasus insists that art means nothing to the Disruptors and they only understand violence. Kirk and Spock are escorted to guest quarters while Droxine admits to her father that she's concerned about Spock. The sentinels bring in a Troglyte prisoner who claims he is a repairman. Plasus doesn't believe him and orders him secured, but the prisoner leaps over the edge and falls to his death rather than reveal anything.
Spock considers the situation while Kirk sleeps, then hears Droxine in the next room. As they talk, Vanna sneaks into Kirk's chamber dressed as a servant and prepares to kill him. Kirk awakens and stops her, and she suggests he call the guards. He'd rather ask her questions but she struggles. Outside, Spock discusses the Vulcan mating cycle with Droxine and Kirk calls them in. Vanna explains that she planned to take Kirk hostage, and that she formerly served in Plasus' household. She believes the Enterprise is there to intimidate the Troglytes. Vanna wants her people to have sunlight and warmth but Droxine doesn't believe they are capable of appreciating it. The sentinels take Vanna away, while Kirk questions Droxine's beliefs concerning the Troglytes. She insists that the society's system is perfectly balanced.
Plasus tortures Vanna for the names of the Disruptors as Droxine looks on. Meanwhile, in their quarters Spock notes that "Troglyte" is a translated term from "Cave dweller." They hear Vanna's screams and go to investigate, and Kirk insists he won't stand by when someone is tortured. Plasus and Droxine stands by their beliefs in the inferiority of Trolgytes and Kirk insists that Vanna won't be tortured unless he is first. Plasus insists that he'll get the zenite for them, but orders them back to their ship. Kirk has no choice but to return to the Enterprise. Plasus orders the sentinels to kill Kirk on sight if he returns.
As the botanical plague spreads, Kirk contemplates the situation. McCoy reports that the Troglytes are mentally inferior, as a result of unrefined zenite gas which causes violent emotional reactions. Spock notes that Vanna was removed from the mines to serve in Plasus' household where she escaped the effects of the gas. McCoy confirms that the effects wear off if exposure is eliminated. He created a filter mask and Kirk tries to convince Plasus of their findings. Plasus doesn't believe them but Kirk wants to offer the masks in return for the zenite. Plasus refuses to consider the matter until his scientists analyze the matter and forbids them from interfering. With only ten hours left, Kirk beams down to Vanna's confinement quarters with the filter mask and tries to convince her of what the Troglytes can gain. Vanna considers his words but wonders if Plasus will agree to the plan. She's skeptical that Kirk will come back to mediate the situation once he delivers the zenite. She finally agrees but says she'll have to guide him there. Kirk agrees, stunning a sentinel and escaping.
Kirk wears the mask and down in the mines, Vanna summons her fellow Disruptors. She takes Kirk hostage and removes the mask, then forces him to dig while taking away his communicator so the Enterprise can't locate him.
While Spock and the crew wait to hear back from Kirk, Vanna beams the filter mask back to Plasus to indicate they have the captain hostage. Vanna's lieutenant Midro wants to kill Kirk immediately but Vanna insists on keeping the captain alive and sends Midro to watch for sentinels. Kirk tries to get through t Vanna and then manages to disarm her. He seals them in using his phaser, contacts the ship, and orders Spock to beam Plasus down to his location.
Plasus is meeting with Droxine and Scotty is forced to delay beaming Plasus out until she leaves. They then send Plasus down to the planet. After an hour, an increasingly irritable Kirk orders Plasus to start digging along with Vanna. When Spock calls down, Kirk cuts him off and they wonder if the zenite is affecting Kirk. The air is running out but when Plasus fights back, Kirk threatens to kill him. Vanna realizes that Kirk was telling the truth and an increasingly angry Plasus challenges Kirk to hand-to-hand combat. Kirk obliges and the two battle. Vanna manages to get the communicator and contacts the ship, and Spock beams them all out. They manage to restrain Kirk long enough for him to regain control and he subdues Plasus.
Back on Stratos, Spock says farewell to Droxine, who plans to go down to the surface to experience all of life. Vanna turns over the zenite but Plasus is unimpressed, but Vanna promises that they will make their demands once the masks have their effect. Kirk offers Federation aid in mediation but Plasus insists on filing charges… until Vanna notes he would be in trouble for assaulting a starship captain. Plasus reluctantly agrees and Kirk and Spock depart with the zenite with three hours to spare.