In the year 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 a damaged ship. When Enterprise enters Klingon space to reach the ship it is attacked by Klingon cruisers and critically damaged. The simulation is named the “Kobayashi Maru”—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 USS Reliant is on a mission to search for a lifeless planet for testing of the Genesis Device, a technology designed to reorganize matter to create habitable worlds for colonization. Reliant officers Commander Pavel Chekov and Captain Clark Terrell beam down to the surface of a possible candidate planet, which they believe to be Ceti Alpha VI; once there, they are captured by genetically engineered tyrant Khan Noonien Singh. Enterprise discovered Khan’s ship adrift in space 15 years previously; Kirk exiled Khan and his fellow supermen from 20th century Earth to Ceti Alpha V after they attempted to take over Enterprise. After they were marooned, Ceti Alpha VI exploded, shifting the orbit of Ceti Alpha V and destroying its ecosystem. Khan blames Kirk for the death of his wife and plans revenge. He implants Chekov and Terrell with indigenous eels that enter the ears of their victims and render them susceptible to mind control, and uses the officers to capture Reliant. Learning of Genesis, Khan attacks space station Regula I where the device is being developed by Kirk’s former lover, Dr. Carol Marcus, and their son, David.
Enterprise embarks on a three week training voyage. Kirk assumes command after the ship receives a distress call from Regula I. En route, Enterprise is ambushed and crippled by Reliant, leading to the deaths and injuries of many trainees. Khan hails Enterprise and offers to spare Kirk’s crew if they relinquish all material related to Genesis. Kirk stalls for time and uses Reliant ’s prefix code to remotely lower its shields, allowing Enterprise to 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 slaughtered members of Marcus’s team. They soon find Carol and David hiding deep inside the planetoid of Regula. 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 then transports Genesis aboard Reliant. Though Khan believes his foe stranded on Regula I, Kirk and Spock use a coded message to arrange a rendezvous. Kirk directs Enterprise into the nearby Mutara Nebula; static discharges inside the nebula render shields useless and compromise targeting systems, making Enterprise and Reliant evenly matched. Kirk exploits Khan’s inexperience in space combat and two-dimensional thinking to critically disable Reliant.
Mortally wounded, Khan activates Genesis, which will reorganize all matter in the nebula including the Enterprise. Though Kirk’s crew detects the activation of Genesis and attempts to move out of range, they will not be able to escape the nebula in time due to the ship’s damaged warp drive. Spock goes to the engine room to restore the warp drive. When McCoy tries to prevent Spock’s entry, as exposure to the high levels of radiation would be fatal, Spock incapacitates the doctor with a Vulcan nerve pinch and performs a mind meld, telling him to “Remember”. Spock successfully restores power to the warp drive and the Enterprise escapes the explosion, though at the cost of his life. The explosion of Genesis causes the gas in the nebula to reform into a new planet, capable of sustaining life.
Kirk arrives in the engine room, as Spock lies dying of radiation poisoning. A space burial is held in the Enterprise ’s torpedo room 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, having soft-landed, rests on the Genesis planet’s surface.