Star Trek II: The Wrath of Khan

The film opens with a female Vulcan, Lieutenant Saavik, in command of the starship USS Enterprise. The vessel is on a rescue mission to save the crew of a damaged ship in the Neutral Zone along the border with Klingon space. The Enterprise is attacked by Klingon cruisers and critically damaged. This "attack" is revealed to be a training exercise known as the "Kobayashi Maru"; a no-win situation designed to test the character of Starfleet officers. Admiral James T. Kirk oversees the simulator session of Captain Spock's trainees.
The USS Reliant is on a mission to search for a lifeless planet for testing of the Genesis Device, a torpedo that reorganizes molecular matter to create hospitable worlds for colonization. Reliant officers Pavel Chekov and Clark Terrell transport down to the surface of a possible candidate planet, Ceti Alpha VI, where they are captured by Khan Noonien Singh. Khan and his fellow genetically-advanced supermen were once rulers on Earth in the late 20th century, but after their defeat they were exiled to space in a sleeper ship. The Enterprise discovered Khan's ship adrift in space fifteen years previously; James Kirk exiled Khan and his followers to Ceti Alpha V after the supermen nearly captured the Enterprise. Khan reveals that after they were marooned, Ceti Alpha VI exploded, destroying Ceti Alpha V's ecosystem and shifting its orbit; Chekov and Terrell have unwittingly landed on Ceti Alpha V. Khan blames Kirk for the deaths of his wife and followers, and plans to avenge them. He implants Chekov and Terrell with indigenous, mind-controlling eels that enter the ears of their victims, and uses the officers to gain control of the Reliant.
The Enterprise embarks on a training voyage under the command of Spock. Kirk, conducting an inspection of the Enterprise, receives a garbled message from Space Station Regula I, a remote science laboratory where Kirk's former lover, Dr. Carol Marcus, and their son, Dr. David Marcus, have been developing the Genesis Device. The Enterprise is ordered to investigate and Kirk assumes command of the vessel. Khan uses a surprise attack to cripple the Enterprise en route, killing many of the ship's trainees. A transmission between the two ships reveals Khan knows of the Genesis Device and wants all materials related to the project sent to him. Kirk stalls for time and disables the Reliant's defenses by transmitting a prefix code. With his ship badly damaged, Khan is forced to retreat and make repairs.
The Enterprise arrives at Regula I, where they find members of the Genesis team dead. The remaining scientists, including Carol and David, have hidden deep inside the planetoid of Regula. Using Terrell and Chekov as spies, Khan steals the Genesis Device. When Terrell is ordered to kill Kirk, the eels' influence wanes; Terrell kills himself while Chekov overcomes the parasite's control. Though Khan believes he is leaving Kirk stranded on Regula I, Kirk and Spock use a coded message to arrange a rendezvous and pilot the Enterprise into the nearby Mutara nebula. Static discharges from the nebula renders ships' defensive shields useless and compromises targeting systems, making the Enterprise and Reliant evenly matched. Khan pursues his quarry against his lieutenant's advice.
Inside the nebula, Kirk uses Khan's inexperience in three-dimensional combat to critically disable the Reliant. Mortally wounded, Khan activates the Genesis Device, which will reorganize all matter in the nebula—including the Enterprise. Though Kirk's crew detects the activation of the Genesis Device and begins to lumber away using impulse engines, with the warp drive damaged they will not be able to escape the nebula in time. Spock goes to the ship's Engineering section to restore warp drive. When McCoy tries to prevent Spock's exposing himself to high levels of radiation, he disables the doctor and tells him to "remember". Spock restores power to the ship, allowing the Enterprise to escape the explosion. Kirk arrives in Engineering just before Spock dies of radiation poisoning.
The explosion of the Genesis Device causes a planet to coalesce out of the nebula. A space burial is held in the Enterprise's torpedo room, and Spock's coffin is shot into orbit around the newly formed planet. Kirk and David make peace, and the crew leaves the planet to pick up the Reliant's marooned crew. In the final scene Spock's coffin is seen to have soft-landed on the planet. Spock narrates Star Trek's "Where no man has gone before" monologue as the camera pans forward into a field of stars.