"A Bomb in Time"
The Enterprise puts in at research satellite 5 to examine their latest development - the Sigma Ray. Dr. Steckler demonstrates the ray to Kirk, Spock, and Scotty. First he uses the Sigma ray to "pierce flesh and clothing", exposing any metal carried by the individual. Dr. Steckler points out that this might be used to design a portable unit to search for weapons and illegal cargoes at great distances. Next, Scotty is levitated by the "A-G Interruptor", which "lays a block of energy between the subject and the strongest gravity source". Then he shows them a "Fire Spider" which has a two-year life span, and lives on nothing but bacteria. Dr. Steckler tells the Enterprise crew that his major breakthroughs have been in the areas of super explosives, and time travel. At that moment, an emergency announcement calls the doctor and the Enterprise crew to the Time Study lab.
They arrive at the lab to find Dr. Lax murdered! Dr. Lax had been the leader of the time travel project. The assistant who discovered the body tells Dr. Steckler that Dr. Lax's last words had been: "The bomb... find bomb!". Dr. Steckler explains that he must have meant the "N-Cycle bomb". He orders his assistant to summon Professor Andres to the time lab. The lab assistant returns shortly, and reports that Professor Andres is missing. He gives Dr. Steckler a reel of video tape that was found in the main recreation area, addressed to Dr. Steckler. On the tape, Dr. Njam tells them that Dr. Andres has stolen the N-Cycle bomb and will explode it on Earth in exactly 24 hours. Using a time travel cabinet, Dr. Andres has gone into another time period on earth so that no one can find him to stop the plan. Dr. Njam demands one billion credits, or he will order Dr. Andres to set off the N-Cycle bomb, which will destroy all of Earth by "setting off the nitrogen cycle".
Spock ponders the evidence at the site of Dr. Lax's death and discovers that Dr. Lax was trying to reset the controls of the time chamber as he died, in order to leave a clue for the others as to Dr. Andres location. He narrows the area down to southern California in either 1955 or 1855. Kirk orders that the ransom effort go forward in order to stall the criminals, while he and Scotty search out the two time periods.
Scotty is sent first - back in time to 1855. (Wearing his Starfleet uniform!) He arrives in a stagecoach, alongside a young Mexican woman and an older gentleman.
After just a short while, the stagecoach is held up by Billy Clancey and his gang. The outlaws begin searching the passengers for valuables. To prevent his phaser from being discovered, Scotty pushes one of the outlaws away. The man draws his gun, and Scotty has no choice but to use his phaser to stun him. The outlaws are awestruck! Scotty offers to sell his talents as a "gunsmith" to the outlaws, and they accept. (The other passengers are less than impressed with his behavior!) Scotty and the outlaws leave the stagecoach and ride away to town. On the way, Scotty learns of a doctor in town who has been performing miracles on the sick. He suspects that it might actually be Dr. Andres using a modern medical kit as a way to obtain room and board.
Meanwhile, Kirk is sent back in time as well. Before he leaves, he orders Mr. Spock to try and hunt down Dr. Njam - who has remained in the present time to collect the ransom money. A terrible mistake happens, and Kirk ends up in ancient Rome instead of southern California in the 1900's. He is stunned, and is nearly run over by a passing chariot. A passerby wearing modern clothes saves him, and asks if he is the stunt man sent over to do the "chariot jump". Kirk realizes that he IS in southern California in 1955 - and has arrived on a movie set. Mistaken for a stunt man, he is led to a meeting with the movie's director, Mr. Bovrille.
While talking to Mr. Bovrille he hears about a new special effects man with amazing talents, especially in the area of rocketry. Since Dr. Andres is a rocket expert, Kirk suspects that the special effects man is really Dr. Andres.
Back in the 1800's, the outlaws are planning a raid on a wagon train hauling Mexican silver. Scotty refuses to give the outlaws his phaser, and insists on going along. The outlaws, however, drug him and take his phaser while he is unconscious. When he awakens, he realizes that the stolen phaser might cause the future to change. He sets off on horseback with two missions: To recover the stolen phaser, and also find the "Doomsday bomb".
Scotty catches up to the outlaws just as they attack the wagon train. Using the stolen phaser, the outlaws are able to quickly overcome more than twenty men. As they begin loading silver on to one wagon, Scotty sneaks up to the wagon train and picks up a six-shooter. He confronts Billy, and the outlaw fires the phaser at Scotty over and over again, just missing him, until finally the phaser runs out of power. As soon as the phaser stops working, Scotty attacks and is joined by the men and women of the wagon train. The outlaws are defeated, and Scotty takes back his lost phaser. He rides into town to see the mysterious doctor that has been performing miracles, but the doctor turns out to be a simple con artist selling "snake oil". (Which according to Dr. Dunsaney will cure lumbago, cataracts, heart seizures, consumption, backaches, and earaches.) Scotty realizes that he has reached a dead-end, and that everything is up to the captain now.
Back in 1955, Kirk is performing a chariot stunt on the movie set in order to get a closer look at rocket work that was done by the new special effects man. He is sure that it is the work of Dr. Andres, and he confronts the man in his trailer. He is correct! Andres picks up a welding torch and attacks Kirk. Kirk is unhurt, but Andres escapes on a nearby chariot. Kirk also steal a chariot, and soon the two are racing down a California freeway, to the amazement of nearby drivers.
In the future - Spock has also captured his quarry, Dr. Njam. He learns that the ransom was the sole idea of Dr. Njam. Dr. Andres simply wanted to hide the bomb in time until the Federated planets promised never to use it. Once Dr. Andres had left to go back in time, Dr. Njam had killed Dr. Lax and planted the video tape on the space station.
Back in time at the movie set, Kirk manages to catch Dr. Andres, and he learns that Andres had no part in the ransom demand. Dr. Andres surrenders the bomb to Kirk, and Kirk promises to try and convince the Federation Council not to produce the bomb. Everyone is returned from the past, and the crew meets back on board the Enterprise - mission accomplished.