In 2285, Admiral James T. Kirk oversees a simulator session of Captain Spock’s trainees. In the simulation, Lieutenant Saavik commands the starship USS Enterprise on a rescue mission to save the crew of the damaged ship Kobayashi Maru, but is attacked by Klingon cruisers and critically damaged. The simulation is a no-win scenario designed to test the character of Starfleet officers. Later, Dr. McCoy joins Kirk on his birthday; seeing Kirk in low spirits, the doctor advises Kirk to get a new command and not grow old behind a desk.
Meanwhile, the starship Reliant is on a mission to search for a lifeless planet to test the Genesis Device, a technology designed to reorganize dead matter into habitable worlds. Reliant officers Commander Pavel Chekov and Captain Clark Terrell beam down to evaluate a planet they believe to be Ceti Alpha VI; once there, they are captured by the genetically engineered tyrant Khan Noonien Singh. Fifteen years prior (see “Space Seed”), Enterprise discovered Khan’s ship adrift in space; Kirk exiled Khan and his fellow supermen to Ceti Alpha V after they attempted to take over his ship. After they were marooned, Ceti Alpha VI exploded, devastating Ceti Alpha V. Khan blames Kirk for the death of his wife and plans revenge. He implants Chekov and Terrell with indigenous eel larvae that render them susceptible to mind control, and uses them to capture Reliant. Learning of the Genesis Device, Khan attacks space station Regula I where the device is being developed by Kirk’s former lover, Dr. Carol Marcus, and their son, David.
Kirk assumes command of Enterprise after the ship, deployed on a training cruise, receives a distress call from Regula I. En route, Enterprise is ambushed and crippled by Reliant. Khan offers to spare Kirk’s crew if they relinquish all material related to Genesis; Kirk instead stalls for time and remotely lowers Reliant’s shields, enabling a counter-attack. Khan is forced to retreat and effect repairs, while Enterprise limps to Regula I. Kirk, McCoy, and Saavik beam to the station and find Terrell and Chekov alive, along with the slaughtered members of Marcus’s team. They soon find Carol and David hiding Genesis deep inside the nearby planetoid. Khan, having used Terrell and Chekov as spies, orders them to kill Kirk; Terrell resists the eel’s influence and kills himself, while Chekov collapses as the eel leaves his body. Khan transports Genesis aboard the Reliant, intending to maroon Kirk on the lifeless planetoid, but is tricked by Kirk and Spock’s coded arrangements for a rendezvous. Kirk directs Enterprise into the nearby Mutara Nebula; conditions inside the nebula render shields useless and compromise targeting systems, making Enterprise and Reliant evenly matched. Spock notes that Khan’s tactics indicate inexperience in three-dimensional combat, which Kirk exploits to disable Reliant.
Mortally wounded, Khan activates Genesis, which will reorganize all matter in the nebula, including Enterprise. Though Kirk’s crew detects the activation and attempts to move out of range, they will not be able to escape the nebula in time without the ship’s inoperable warp drive. Spock goes to restore warp power in the engine room, which is flooded with radiation. When McCoy tries to prevent Spock’s entry, Spock incapacitates him with a Vulcan nerve pinch and performs a mind meld, telling him to “remember”. Spock repairs the warp drive, and Enterprise escapes the explosion, which forms a new planet.
Before dying of radiation poisoning, Spock urges Kirk not to grieve, as his decision to sacrifice himself to save the ship’s crew was a logical one. A space burial is held and Spock’s coffin is shot into orbit around the new planet. The crew leaves to pick up Reliant’s marooned crew from Ceti Alpha V; Spock’s coffin is shown having soft-landed on the surface of the Genesis planet.