Orbiting the planet Lactra VII, the Enterprise is on a mission to investigate the fate of the S.S. Ariel and its six-member scientific crew, which have disappeared. A message from the ship's captain, Lieutenant Commander Tom Markel, sheds little light on the situation, only revealing that he violated rules and beamed down to the planets surface with the last two members of his crew, in an attempt to find and rescue the other three crewmembers.
Captain Kirk, Mr. Spock, and Dr. McCoy beam down to the planet's surface, whereupon they encounter boiling hot springs and a large red cyclopean water dragon. Tracing the path of a communicator signal, they are imperiled by an immense grey monster, whose phaser-stunned form soon crushed McCoy beneath its falling bulk. They soon discover that the planet's surface is terraformed in a random pattern. Shortly thereafter they are captured by giant orange slug-like beings, and taken to a massive city.
The trio learn that the slugs are super-intelligent beings known as Lactrans, but they soon also learn that they are being kept as specimens in an interplanetary zoo, along with the three remaining crew of the Ariel. The advanced Lactrans have no plan to release the humans, until a trick by Kirk causes a "baby" Lactran to be beamed aboard the Enterprise. There, Scotty manages to teach it about Starfleet and the Federation.
The baby returns to its parent, and convinces them that the backwards simple-minded humans are in the process of evolving. Allowing the humans to return to the Enterprise, the Lactrans inform Spock that they will be welcome to come back ... in 20 to 30 centuries!