"The Cosmic Cavemen"
While in orbit around the uncharted planet Neesan, sensors detect intelligent life forms on the surface. The life forms are undeveloped, and the planet is in it's "Stone Age." Kirk orders the crew not to interfere with the social and political structure of the planet - especially since it is at such an impressionable time. Scotty comments that leaving even a button behind could change the whole future of the planet. "All they could learn from you, Scotty, is how to play an electronic bagpipe!" McCoy quips.
Kirk leaves Spock in command of the ship, as he, Scotty, and McCoy transport to the surface (In full Starfleet uniform - the Prime Directive notwithstanding) in order to take a look at the inhabitants of the planet. As soon as they materialize, the landing party hears a loud noise like "10,000 Vulcan palm trees caught in a solar-wind storm", and are attacked by primitive men carrying stone-bladed spears and riding pterodactyls. Kirk orders McCoy and Scotty to fall back and protect themselves, using phaser stun power only. McCoy is hit in the head with a stone axe and falls to the ground unconscious. The cavemen begin to overwhelm them, and Kirk decides the only way to avoid killing the primitives is to surrender to them.
The landing party makes a break for it. Scotty runs up to a large flaming pot, and burns away the rope that ties his hands together - and then knocks the heads of two cavemen together as soon as he is free. Scotty, Kirk, and McCoy are about to overcome the primitives, when Queen Lok throws "Backi Powder" (for the "sleep of eternity") at them. The crew begins to cough and choke - and finally pass out. Queen Lok tells them that when they wake, they will be in the "halls of eternal rest." The unconscious Kirk is placed on an execution block, and a caveman wearing a green bug-like mask prepares to chop off his head.
The landing party is taken back to a cave in the village, and given medical treatment and food (served by a bevy of beautiful women). Spock arrives at the cave wearing ceremonial robes, and dismisses the servants. He tells Kirk that the cavepeople are called the Tol, and that a more barbarous tribe called the Kovars are about to attack. The landing party is not allowed to help the Tol, who stand no chance against the Kovars. Kirk turns to ask Scotty a question and discovers that he is missing!
"[Scotty, as it appears, is in good - and beautiful hands!]" as Queen Lok shows him the Crystal Flowers of Xamgina, and the Golden Fonts of Lydo - wonders of the cavemen's world. All of a sudden, a Kovar rushes out of the trees to attack, riding an animal that looks rather like an enlarged armadillo. Scotty and Queen Lok try to run away. Lok catches her foot on a branch and tells Scotty to go on without her, but Scotty takes her up in his arms and carries her through the forest back to the village, and the others.
Kirk and Scotty beam back down to the surface in order to recover the lost phaser. They narrowly escape being seen by a large group of Kovars that are on their way to attack the Tol. The battle begins, and the Tol take heavy losses. Queen Lok prepares to use the stolen phaser against the Kovars, but Scotty walks up to her and distracts her, and Kirk knocks the phaser from her hand. Queen Lok despairs that the statue to their god Unruho will be destroyed without the phaser, and Scotty comforts her for a moment. Kirk and Scotty are forced to run away when the Kovars approach. They flee into a nearby canyon, and close the entrance with phaser fire - hoping they will be safe. The Kovars, however, attack from the cliffsides, and knock both Kirk and Scotty out.
Meanwhile, aboard the Enterprise - Spock ponders why the Tol believe him to be a god, and why a statue of him was made. He finally solves the puzzle. He remembers one of the first missions for the Federation, when he was on the planet Dukar and had been attacked by a huge, horrible creature that "chilled his very bones." Spock had had an uncontrolled reaction, and made a mental cry for help that Lok had "seen" due to her mental abilities. He attempts to contact Kirk and Scotty to tell them what he has learned, but is unable to reach them.
Aboard the Enterprise, tempers flare! Spock says to Scotty: "I see your cave queen gave you a little posey by which to remember her, Mr. Scott! How touching!" Scotty shouts back: "I'll touch your nose with my fist if you keep that up, Mr. Spock! You've been asking for this for a couple of light-years now! All right, let's go!" Kirk steps in to hold Scotty back and tells them both that the next one who pops off will be "wiping pipes for a month in the nuclear furnace room."