Star Trek: The Menagerie

On stardate 3012.4, the USS Enterprise diverts to Starbase 11 when Mr. Spock receives a subspace call from the former captain of the Enterprise, Christopher Pike (under whom Spock served for 11 years, and since promoted to Fleet Captain). When the ship arrives, the commander of the starbase, Commodore Mendez (the first appearance of a rank higher than Captain in the series), states that communication with Pike is impossible, since he has been severely burned and paralyzed by exposure to delta rays during a maintenance accident aboard a J-class training vessel. He couldn't have possibly sent the message. In fact, it is revealed that Pike is confined to a wheelchair operated by brainwaves. He cannot speak, and only communicates with a flashing light: one flash means "yes", two flashes mean "no".
Pike is at the station, and refuses to talk to either Captain Kirk or Dr. McCoy and only allows his old friend and former officer, Mr. Spock, to talk with him in private. Spock partially explains his appearance by indicating his intention to take Captain Pike against Starfleet regulations.
Back in Mendez's office, Kirk discovers that the communication logs reveal that Spock had not received any messages from Pike at all, and can't understand his deception. Spock sneaks into the station's computer center, nerve-pinches the technician, and proceeds to override the computer system, sending the Enterprise fake orders to go to the quarantined planet, Talos IV. He informs the navigation chief on the bridge that the navigation data will automatically pilot the ship. He overrides the voice authorization protocols with bogus recordings of Kirk's voice. The bewildered navigator accepts the strange authorization and Spock uploads the data. Meanwhile, another station technician enters the computer room and confronts Spock, but Spock easily subdues him with another nerve pinch.
Dr. McCoy is tricked into returning to the Enterprise by a request for medical assistance, after which Mendez shows Kirk a secret file on the fate of Talos IV. The file contains minimal background information on an earlier mission to Talos IV, not even explaining why unauthorized passage to Talos is grounds for the death penalty under Starfleet General Order 7. Spock then transports himself and the disabled Captain Pike aboard. By the time a duty nurse notices Pike is missing, the Enterprise has left orbit about Starbase 11 and warped away to Talos IV.
Kirk and Commodore Mendez head out and follow the Enterprise with a starbase shuttlecraft. Spock detects the pursuing craft, which is rapidly exhausting its fuel reserves just to keep up, and surrenders himself to the Enterprise crew for arrest, confessing that he mutinied and that he never received command orders. The Vulcan is taken away. Commander Scott beams Captain Kirk and Commodore Mendez aboard. They demand that the system's computer explain Spock's actions and return control of the ship to the navigator. The computer informs them that any attempt to override the navigation computer will disable ship's life support, and that the system cannot disengage until the Enterprise has reached Talos.
Commodore Mendez orders a preliminary hearing on Spock, who requests immediate court martial, which requires a tribunal board of three command officers. Spock points out there are three already there – Kirk, Mendez, and Pike, who is still listed as being on "active duty". Spock begins showing video footage of the recorded events that took place during "The Cage" to explain how this "story" begins.
The video recounts how 13 years earlier the Enterprise, commanded by Captain Pike, received a weak distress signal from the SS Columbia, a survey ship reported lost 18 years earlier. The Columbia reportedly crash-landed on Talos IV.
A landing party beams down and a few remaining survivors are found, including a young woman, Vina, who was born shortly before the Columbia's crash, and whose parents had died. Pike immediately takes an interest in her. Unknown to Pike and the others, they are being monitored by the planet's native inhabitants, the Talosians, who can create very realistic illusions and wish to study the humans that have come to their planet.
Dr. Boyce, Pike's chief medical officer, monitors the survivors but finds them in remarkable health, far better off than he expected and becomes suspicious that something isn't right. Before he can inform his Captain, Pike is lured away into a Talosian trap by Vina. Pike disappears behind a stone door and the survivors all disappear, having been only illusions.
Part one ends when Kirk discovers that the images Spock is showing are actually being transmitted to the Enterprise from Talos IV, and Starfleet orders a stop to the transmission. The court stands in recess as the final credits roll.
The trial continues at Kirk's request, even though Starfleet has denied the Enterprise further access to the Talosian transmission. The recordings show Pike in a cage, and he learns that the Talosians wish for him and Vina to mate and produce offspring so that the Talosian captors can rebuild their destroyed civilization. Aboveground, Pike's crew frantically try to rescue him, but cannot get past the first hurdle, a door which not even the ship's weapons can penetrate. A larger problem is that the crew cannot trust their own senses, as the Talosians are capable of casting illusions on the planet's surface as well as underground.
The aliens send Pike through numerous virtual realities with Vina, hoping that the settings will move his interest with the girl into passionate love for her, and the two will copulate. However, Pike resists their mind games and demands to be set free, but the Talosians threaten him with traumatizing illusions to punish him, inflicting a few agonizing seconds of an illusion of Hell on him to make their point. The Enterprise attempts to beam a landing party directly into the Talosians' underground network in order to rescue Pike. The Talosians, aware of this raid, manipulate the transport operators so that only female crew members beam into the cage thus providing Pike with a wider choice of 'mates'. Furthermore, the new captives' fully charged phasers are seemingly rendered inert, thus precluding the option of shooting their way out.
That night, Pike captures a Talosian attempting to confiscate the guns while the captives sleep. Pike tells his new prisoner that he believes that the phasers had successfully burned through the cage wall, but the results were hidden by illusion. Pike threatens to test out the theory by shooting the Talosian unless the phaser damage is revealed. The Talosian complies and reveals the large hole in the transparent cage wall, and the humans escape. However, upon reaching the surface, the Talosian reveals that they were allowed to escape so as to settle the new slave colony on the planet's surface.
In reaction, Number One sets her phaser on overload to kill all of them instead of being enslaved. She is persuaded to deactivate her weapon when more Talosians arrive with the results of their scan of the Enterprise's records and reveal that humans are far too dangerous and violent for their needs — the humans are free to go. When Pike complains that they are getting away with kidnapping and threatening himself and his crew, the Talosians explain that their captives were the last hope for the survival of the Talosian species, which is now doomed.
Number One and Yeoman Colt are beamed back to the ship, while the Talosians hold Pike for just a few moments longer. Vina is revealed to be hideously deformed, the results of the injuries she sustained in the crash of the Columbia and her beauty was only maintained by a Talosian illusion. As Pike leaves he requests her illusion be restored. After the Keeper replies "and more" Vina is immediately transformed back to health. Pike leaves, satisfied that Vina is happy to live on Talos with an illusion of beauty. Suddenly the video transmission ends and Kirk understands what Spock has been planning. Pike, now disfigured and disabled, can be "revived" by the Talosians' power.
To Kirk's surprise, Commodore Mendez suddenly disappears, having been a Talosian illusion, created so he could force Kirk to watch Pike's story, and delay regaining control of the ship and diverting away from Talos IV. Starfleet Command, which has been watching the trial footage from Starbase 11, gives Kirk official permission to finish the journey to Talos IV and beam Captain Pike to the planet.
Spock is cleared of all charges against him. Kirk demands to know why Spock did not tell him what he was planning so he could help. Spock explains that doing so would have put the captain at risk of execution himself while Spock could manage on his own. Kirk expresses concern about Spock's mental state, but the Vulcan maintains that he has been "logical about the whole affair". Spock sees Pike out, and once Pike is beamed to Talos, the Talosians return the former captain to his normal state (via illusion). Pike is reunited with Vina. The Talosians' final message to Kirk is "Captain Pike has an illusion, and you have reality. May you find your way as pleasant." The Enterprise then leaves Talos and returns to Starfleet.