
The crew of the U.S.S. Enterprise is ready for some down time, and they head to the so-called "shore leave" amusement park planet in the Omicron Delta region. Dr. McCoy, along with Lieutenants Uhura and Sulu, beams down to the surface, and soon encounter the familiar White Rabbit and Alice from their earlier trip to that world. A short while later, McCoy visits an old-style Southern plantation, but he is soon attacked by the Queen of Hearts and several of her playing-card confederates.
With an emergency beam-out, McCoy and Sulu are safe, but Uhura is trapped when a hovering robot steals her communicator. Kirk discusses the matter with his crew, and has all other landing parties recalled. Kirk takes a group with him to rescue Uhura, unaware that the Master Computer controlling the world has decided to "turn them off," despite Uhura telling it that the act would be murder. The Computer sends an energy block, cutting off the Enterprise's communications and transporter beams, and prevents the launch of an emergency shuttlecraft!
Meanwhile, Kirk and the others find the Caretaker of the planet's tombstone, and realize that after his death, the planet and its Master Computer and robot inhabitants have become dangerous! The rescue party is soon imperiled by pterodactyls and a giant cat, and the Computer gains control of the Enterprise until Mr. Arex locks it out with manual control overrides.
Faking an injury to Spock, Kirk manages to gain access to the underground control complex, while Sulu and McCoy face a two-headed fire-breathing dragon, and the Enterprise crew deals with the loss of gravity aboard the ship. Below, Kirk, Spock, and Uhura convince the Computer that it is useful, and it can find fulfillment making other visitors happy. The Computer finds their argument logical and relents its attacks, leaving the Enterprise crew to begin their shore leave anew.