Set in the 23rd century, the series follows the adventures of Captain James T. Kirk (voiced by William Shatner) and the crew of the Starfleet starship Enterprise. In this episode, after the Enterprise passes through an unusual cloud the ship's computer starts playing practical jokes on the crew.
On stardate 3183.3, The FederationstarshipEnterprise is attacked by three RomulanD-7 class battlecruisers. Captain Kirk orders the ship into a nearby gaseous energy field to hide, knowing that the Romulans would be unwilling to follow in after them. Sometime later, the crew begin to suffer a series of practical jokes, beginning with glasses leaking and utensils turning to rubber, a uniform tunic for the captain with "Kirk is a Jerk" emblazoned on the back, and a mysterious optical device on the bridge science station which when looked into leaves blackened circles around Science Officer Spock's eyes. Everyone expects that there is a member of the crew having fun. The jokes become more serious, however, as corridor decks are found covered with ice under a concealing layer of fog. Still thinking that a crewmember is responsible, Chief Medical Officer Dr. McCoy, Lt. Uhura, and Lt. Sulu hope to escape the jokester by hiding out in the ship's Rec Room.[note 2] No escape is to be found as a quiet stroll in a woodland scene becomes dangerous with the program parameters changing to include a deep pit covered over by branches and leaves, and later a freezing cold blinding snow storm then a hedge maze before they are finally rescued.
Eventually the practical jokester, which has turned out to be the Enterprise computer itself (affected by the ship's passage through the energy field), decides to play a practical joke on the Romulans for the battle damage caused in the earlier attack. It fabricates a gigantic ship-shaped balloon beside the Enterprise that the Romulans are drawn to attack. The Romulans, infuriated over the embarrassment of being tricked, give chase. Kirk immediately shows extreme fear at the prospect of returning to the cloud to escape the Romulans, and the Enterprise presses into Kirk's fear by taking the ship back in. The jokester personality of the computer begins to fade, as it realizes it had been tricked itself, and finally returns to normal. The Romulans, however, were so enraged over the balloon-ship ruse that they follow the Enterprise in this time and begin to experience a rash of jokes themselves.
^The "Rec Room" in this episode is the forerunner of the "Holodeck" (introduced in the Next Generation pilot "Encounter at Farpoint") which plays a significant part in numerous episodes of the subsequent spin-off Star Trek series.