The U.S.S. Enterprise arrives to investigate reports of an unknown monster deep in the mining tunnels of Janus VI. The being is apparently destroying machinery and killing the miners, and has the ability to burrow through solid rock. Janus VI is a source for the rare mineral, pergium.
Soon after the landing party arrives on the planet's surface, a reactor pump is stolen and the colony is in jeopardy from fluctuating life support functions. However, this convinces Spock that they are dealing, not with a mindless monster, but with an intelligent lifeform.
Kirk and Spock, along with members of the ship's security team, enter the mines to find the creature. They discover a large, rock-like creature that burrows easily through the stone walls, as a mole might burrow through dirt. Wounded in a phaser blast, the bulky creature manages to escape through the stone wall.
They continue pursuit and eventually Kirk is trapped by the creature. When it doesn't attack, Spock attempts a Vulcan mind meld with the entity and discovers that it is, in fact, an intelligent being. A native of the planet, the creature is normally peaceful, and called a Horta. It doesn't mind sharing the planet with the miners, but when the men broke into the Horta's hatchery and unknowingly destroyed many of her eggs, it attacked to protect its remaining unborn children.
With Spock acting as interpreter, the miners explain that they thought the eggs were some king of silicon nodules and that no hostility had been meant.
McCoy treats the silicon-based creature with a trowel and patch material, and heals it. An alliance is formed between the Horta and the miners; the young, newly-hatched Hortas will mine the pergium at a far faster rate than the humans could and the miners will be extremely rich. Kirk retrieves the missing reactor and the landing party leaves the inhabitants of Janus VI living in peaceful co-existence.