The Enterprise is dispatched to the planet Lactra 7 to find a missing science vessel, the Ariel, and its six-man crew. They find the Ariel floating in orbit, abandoned, and the command crew review the last log from Lt. Commander Markel. Markel lost contact with three members of his landing party and made the decision to go down with his remaining two officers to look for them. Kirk points out that Markel's actions were a violation of Starfleet protocol, and Spock reports that Lactra 7 is a Class M planet. However, they have no other information on it. The last log entry is five weeks ago, and Kirk tells Spock and McCoy that they'll be beaming down to the same coordinates that Markel used.
The landing party arrives on the planet next to a boiling lake. A dragon-like amphibious creature attacks them and they easily drive it off with phasers. As they begin exploring, Kirk tries to contact the Ariel crew on his communicate. They receive a carrier signal indicating someone at the other end is listening, but no verbal response. Kirk triangulates on the other communicator and they head away from the lake... and abruptly find themselves in a desert with no lakes. A gigantic rock-like creature attacks them and they manage to stun it by focusing their phasers on its neck. The creature collapses on top of McCoy and Kirk and Spock manage to dig him out.
As they follow the bearings from the other communicator across the desert both Spock and Kirk recognize the desert landscape as similar to another planet they've visited. They come to a rain forest just as abruptly as the desert began, and Kirk contacts Scotty. The engineer informs them that they've detected a large group of lifeforms 98.5 kilometers ahead of them on the same bearing. As McCoy prepares to take a drink of the lake water, Spock scans it first. He admits that it's good to drink, but points out that it is too pure. The science officer suggests that the entire area is terraformed. When McCoy points out that there is no apparent pattern to the layout of the adjoining areas, Spock suggests that is the pattern.
A horde of flying creatures suddenly the three officers, who open fire. The creatures continue but Kirk tells them that he's seen the creatures before and sustained phaser fire will drive them off. However, the creatures suddenly hit an invisible barrier and retreat, and Spock notes that it's a forcefield. Before they can analyze it, three large slug-like creatures grab the landing party with their prehensile trunks and cart them off.
The creatures continue slithering across the landscape and the Enterprise officers realize that they are continuing on the same bearing. They finally reach a large advanced city at the point that Scotty indicated. The creatures take their equipment, deposit the three officers inside a metal chamber, and seal the entrance with a forcefield. Spock says that he's receiving fleeting mental impressions but is unable to identify them. McCoy realizes that they're in a decontamination chamber and assumes that Lactrans are measuring their intelligence.
Once the decontamination is over, the creatures move them to another chamber and seal it. Spock tells Kirk and McCoy that the creatures are telepathic and thinking at a mental rate thousands of times faster than their own. As for the mixed environments, Spock believes that their captors, the native Lactrans, have traveled to other planets and created a "zoo" of landscapes and creatures for their edification. Kirk wonders why the creatures don't recognize them as intelligent beings rather than animals, and Spock suggests that the creatures may believe that they found the equipment, that they may assume that they're toys, or that they may not even recognize their relatively primitive gear as a sign of intelligence.
The Lactrans finally remove the landing party from the cell and take them past a number of cells holding other animals. Finally they arrive at Earth-like habitat, complete with a house. Once the Lactrans seal the Enterprise officers in, Markel and his biologist, Randi Bryce, come out and introduces themselves. When Kirk wonders why they didn't respond to his communicator signal, Markel explains that their equipment is on a display table outside of the environment. The Lactrans were experimenting with it and activated it. Markel explains that the first landing party was killed by one of the zoo creatures before the Lactrans found them. When Markel, Bryce, and his other officer, Lt. Nancy Randolph arrived, the Lactrans captured them. Randolph now has a high fever, and McCoy tries to treat her without his medikit. Meanwhile, Markel confirms Spock's theory that they're in an alien zoo, and admits that all efforts to communicate have elicited no response.
While two of the Lactrans watch them from outside, Markel explains that their captors kept them in a plain cell until they read the crew's mind and built the habitat for them. Spock tries to contact them with his Vulcan abilities and the creatures start quivering. Disgusted, Spock tells the others that the creatures appear to be laughing at his childish efforts. They check on McCoy, who tells them that Lt. Randolph has a malaria-like infection. However, there's nothing he can do for her without his medikit. Markel points out that the creatures outside are their guards, and they bring supplies once a week to the same place near the display. When McCoy warns that Randolph could die without medical treatment, Spock tells him to focus on that thought.
The Lactran guards bring fruit in and Markel says that it's ahead of schedule. Kirk figures that McCoy's thoughts are too weak, relatively speaking, and everyone concentrates on the medikit. A Lactran finally gives the medikit to McCoy, who treats Randolph. Meanwhile, Markel figures that the Lactrans want to make them happy... but only as zoo animals. Spock warns that the Lactrans will be very reluctant to let their zoo animals go.
Later, more Lactrans gather outside to watch their new additions. Spock tries to interpret their fleeting mental impressions and discovers that they frighten the younger ones, while the females find them ugly. McCoy worries that Scotty might launch an attack despite his orders not to send a landing party, and Spock notes that the Lactran forcefield would repel the Enterprise's weaponry. He suggests that they contact the Enterprise by convincing the Lactrans that one of them is ill and that a communicator would cure them.
Kirk plays the sick crewman and they go near the display case. A smaller "child" Lactran is there and when the crewmen concentrate, the Lactran picks up one of the communicators and enters the habitat. It puts the communication in front of Kirk, who snatches it up and calls the Enterprise for transport. The child snatches it away just as Scotty activates the transporter, and the engineer finds a large slug in the transporter chamber.
On Lactra, the adult aliens panic and Spock warns his fellow crew that their captors have now assessed them as a deadly species. The two Lactran parents telepathically assault Kirk, demanding to know where their child is. As Kirk tries to resist, Spock warns that the Lactrans' accelerated thoughts could drive Kirk mad if he lets them through.
The Lactran child carries Scotty to the bridge, and the engineer orders everyone to leave. Once they're alone, Scotty tries to get through to the newcomer. It ignores him, takes control of the Enterprise, and sends the starship careening out of orbit.
On Lactra, the two parents fail to penetrate Kirk's brain. Unfortunately, they summon three more of their kind to increase their strength. Spock has the others unite their mental forces to shield Kirk as best they can. Before the Lactrans can destroy Kirk's mind, Scotty beams down with the Lactran. The parents yank it out of the habitat while Scotty tells the others that the child is their equivalent of six years old, although Lactrans age far more slowly. It has an IQ in the thousands and tapped into the Enterprise computers to learn everything about humanity and the Federation. Realizing it was dealing with an intelligent species, it then slowed down its thought and made contact with Scotty, who convinced it that he wasn't a pet. The Lactran child then returned the Enterprise to Lactra and beamed down with Scotty.
The Lactrans adapt their child's slower thought patterns and contact Spock directly. They've concluded that humans and Vulcans are simplistic creatures, but intelligent beings in the process of evolving. The Lactrans are tens of thousands of years more evolutionarily advanced but release the Earthlings, believing that no intelligent being should be in a cage. Scotty says goodbye to his new friend and they beam back up.
As the Enterprise leaves Lactra, Markel regrets that they learned almost nothing about the planet they came to study. Spock tells him that there will be opportunities, and informs them that the Lactrans have sent one last message. The Federation is welcome to come back and meet with them... in 20 to 30 thousand Lactran years.