Stardate 3196.1: On the mining colony Janus VI, the chief engineer Vandenberg leads a party through the tunnels to relieve a sentry. Something has killed 50 miners. They leave the sentry on duty with the assurance that the Enterprise will be arriving soon. As soon as the party leaves, the guard is attacked by the same creature and the others return to find his burnt corpse.
Upon arrival, Kirk, Spock, and McCoy beam down and meet with Vandenberg. The monster has been attacking them since they opened up a new vein three months ago. First the machinery dissolved and the first man sent to investigate was seared to a crisp. The deaths have been moving up and the last man died three days ago on one of the upper levels. As McCoy goes to check out the body, one of the other miners describes how he saw a glimpse of the creature: big and shaggy, and resistant to phaser fire. Spock notes a spherical silicon nodule, one of thousands discovered by the miners, and is intrigued, but Vandenberg is more concerned with stopping the miner. McCoy determines that the men were killed by exposure to corrosive acid. Production of the valuable pergium is being cut off and Kirk needs to get it going.
At the colony's reactor chamber, a guard hears a rustling noise and goes to investigate, and is killed by the monster. The creature then enters the reactor room and the power begins to fluctuate. Kirk, Vandenberg, and the others go to find the guard dead and a hole in the door. The main circulating pump is gone and they have no replacement. The reactor will go super-critical and destroy the colony,
Scotty tries to rig up a replacement but it won't last more then 48 hours. Spock concludes the pump was deliberately stolen but Kirk wonders why it's only attacking now. Spock connects the creature's recent activities to the silicon nodule, and believes that a silicon-based creature may be responsible. Kirk accepts the theory and suspects it has a thick enough hide to resist Level I phasers. They distribute Level II phasers adjusted to affect silicon, while Spock is still intrigued by the nodule.
Kirk sends out his security guards to hunt down the creature and Spock suggests they go to Level 23 where they first found the nodules. Kirk and Spock go out and Spock detects traces. One of the Enterprise guards is attacked and killed by the creature and Kirk and Spock investigate to find a charred corpse. Spock discovers a perfectly round tunnel that was created only moments ago. They hear a rumbling noise and spin to see the creature emerge from another tunnel. They open fire and drive it back into a maze of similar tunnels. They pick up a piece of the creature left behind that resembles fibrous asbestos. Kirk believes the creature is now dangerous then ever since they've wounded it.
Spock pinpoints the creature on his tricorder but notes there is only one creature and thousands of tunnels. He concludes the creature is the last of its race and to kill it would be a crime against science. Kirk has no choice but to dispose of the creature, over Spock's concerns. Later at the briefing, Spock suggests they try and capture the creature and Kirk calls him on it. Kirk suggests he assist Scotty so they're not both at risk but Spock points out the odds of them both being killed is unlikely. Kirk orders an evacuation but Vandenberg and some of his men opt to remain. After sending the miners out with Enterprise personnel, Spock notes that they're being watched. He detects fresh readings and they split up to go down two different creature-tunnels to a common point. They stay in touch and Kirk discovers more of the nodules. Spock warns him not to damage them but then the creature, lurking in the tunnels, brings down rocks on Kirk behind him. He's okay and prepares to continue on ahead, but the creatures bores its way out of a wall and comes directly for him.
The creature holds off as Kirk keeps his phaser on it. When he drops the phaser it approaches, and backs up when he reaims. However, it also moves to block his path when he tries to get around. Spock checks in and Kirk tells him he's facing the creature but is reluctant to kill it. The creature reveals its wound and Spock arrives, but Kirk tells him not to shoot. Spock joins up with Kirk and points out the nodules. He suggests that he perform a mind-meld with the creature and it allows him to approach. Spock begins to receive thoughts of great pain and falls back. The creature then goes to a rock and burns the words "No Kill I" on the surface. Kirk wonders if it's a plea for a mercy or a promise to them. Spock reveals the creature is highly intelligent and calls itself a "Horta." Kirk needs Spock to touch it directly and find out about the pump and why it turned to murder.
The Horta lets Spock touch it and he establishes a mind meld, while Kirk has his security guards hold back the miners at the tunnel entrance, but let McCoy through. Spock begins channeling thoughts of the thousands dead and the end of eternity, and mentions the "Chamber of the Ages." McCoy arrives and Kirk wants him to tend to the Horta's wound but the doctor isn't confident. Spock manages to get the information about the reactor pump and directs Kirk to its location in the Chamber of the Ages.
The miners give the security guards a hard time while Kirk finds the Chamber filled with broken nodules. He brings one back along with the pump and gets Spock to break out of the mind-meld. Spock reveals that the nodules are eggs and they're about to hatch. The miners destroyed thousands of them.
The miners burst past the security guards and prepare to open fire on the Horta, but Kirk tells them to back down and explains they've been destroying the Horta's eggs. Spock explains that once every 50,000 years all but one of the Horta die, and the remaining one guards the eggs and becomes the mother to the new generation. Spock notes the creatures normally harbor ill-will toward no one, and Kirk gives them the circulating pump. He notes that they can use the Horta to get at the mineral deposits if they can make an arrangement, if it lives. McCoy reveals that he's saved the Horta using quick-dry concrete.
Later after Spock arranges the deal and they prepare to depart, Vandenberg calls in to say the eggs have started to hatch and the baby Horta are finding huge amounts of ores. Spock notes that the Horta found humans ugly, but did like Spock's ears.