A space probe of unknown origins scans the Federation and then self-destructs near Earth. Starfleet sends the Enterprise back along its route to find its source. As they start to lose the trace, they detect an approaching vessel of unknown origins. Kirk orders Ensign Walking Bear, the acting helmsman, to reduce speed. The vessel is twice the size of the Enterprise and made of a crystalline ceramic. It surrounds the Enterprise in a spherical force field and they are brought to a stop.
The alien ship then opens fire on them and projects an energy field giving it the appearance of a winged serpent. Ensign Walking Bear recognizes it and says the name Kukulkan. Upon the ensign speaking the word, the alien ship stops firing. Its captain contacts them and says that it was prepared to destroy them because they had forgotten, but one among them knows his name. The alien tells them he will give them one chance to pass its test, a test that their ancestors failed. Walking Bear, a Comanche, explains that the alien ship is similar in appearance to Kukulkan, an ancient Mayan/Aztec god. Spock uses the ship's computers to confirm and notes that many ancient cultures have similar legends of winged serpents that provided knowledge and guidance. They realize that they may be dealing with a space traveler who was the basis for all of Earth's legends.
Before they can pursue the matter, first McCoy and then Scotty are teleported off the Enterprise. Walking Bear disappears a few seconds later. Kirk barely has time to sound an alert before he disappears as well. They all find themselves on the alien ship in a vast empty space, stripped of all their equipment except McCoy's medikit. Kirk calls upon Walking Bear to explain, and the ensign describes how all the legends say that Kukulkan left Earth but promised that he would one day return. Kukulkan's voice booms out, telling them he will give them clues that they must decipher so that they can summon him.
A vast city springs up out of nowhere with a pyramid in the center, surrounded by four serpent-headed obelisks. They examine the city and realize it's made up of architectures from hundreds of different Earth cultures. Walking Bear notes that according to the legends, Kukulkan told the Mayans to build a city to exact specifications, and that once they did he would return. They conclude that each culture failed to build to the exact specifications, and now Kukulkan is presenting them with his ideal city so they can summon him. As Kirk climbs to the top of the pyramid, Walking Bear and Scotty examine one of the obelisks. Kirk finds a crystalline platform at the top and realizes that the sun hasn't moved. Realizing it's the key, he tells them to turn the head of the obelisks. Each head focuses a beam of sunlight on the crystalline platform, triggering an energy signal that summons Kukulkan, a flying winged serpent.
Kukulkan dismissively tells them to try and use their weapons of destructions, accusing them of hating him. Kirk says they only use weapons in self-defense and wonders why Kukulkan attacked them. Kukulkan says that they are his property, to do with as he wishes. He demands their obeisance. When they refuse, Kukulkan says it his duty to teach them what they have forgotten. He causes the city to disappear, revealing a vast alien zoo. Each specimen is in a transparent cell, comfortable despite their crowded surroundings. Kukulkan explains that all of the creatures are peaceful in their natural environment, and the cages project a mental illusion of that environment. He asserts that it is Man who is violent. When he visited Earth, he tried to teach them a better way.
Kirk argues that Kukulkan has no right to interfere in other cultures, but the alien asserts that he is the last of his race and sought to civilize a race so that he could have companionship. He directs their attention to a Capellan Power-Cat, living peacefully despite its violent nature. McCoy recognizes the creature, which is incredibly ferocious and capable of discharging bolts of electricity. Kukulkan considers humans as unruly children, but Kirk argues that all children grow up and become independent. Furious, Kukulkan attacks them.
Spock has been working to try and free the Enterprise, and determines that the force field can only absorb energy at one point at a time. Using the tractor beams and warp engines in opposite directions, they blast themselves free and then open fire on Kukulkan's ship.
The alien prepares to open fire and Kirk and McCoy pull a cable on the cage holding the power-cat. The power-cat smashes free, blasting open other cages and spreading chaos. The Enterprise phasers disable the alien ship's power source, leaving Kukulkan defenseless against the power-cat. Kirk takes a hypo from McCoy's medical kit and injects the power-cat with a sedative at maximum dosage. The power-cat blasts Kirk back with electricity and then settles down. Kirk insists that they have earned the right to be heard. He explains that they're trying to live peacefully but they have grown up and are no longer dependent on their "teacher." Kukulkan reluctantly agrees to let them go their way while he departs.
Back on board the Enterprise, they watch as the alien departs. Spock notes that the Vulcans had similar legends but that it was the aliens who left the wiser. Kirk regrets the loss of an alien of such power and knowledge, but notes that the price Kukulkan demanded was too high.