After the lackluster critical and commercial response to Star Trek: The Motion Picture, series creator Gene Roddenberry was forced out of the sequel's production. Executive producer Harve Bennett wrote the film's original outline, which Jack B. Sowards developed into a full script. Director Nicholas Meyer completed the final script in 12 days, without accepting a writing credit. Meyer's approach evoked the swashbuckling atmosphere of the original series, and the theme was reinforced by James Horner's musical score. Leonard Nimoy only reprised his role as Spock because the character's death was intended to be irrevocable. Negative test audience reaction to Spock's death led to significant revisions of the ending over Meyer's objections. The production used various cost-cutting techniques to keep within budget, including utilizing miniatures from past projects and re-using sets, effects footage and costumes from the previous movie. Among the film's technical achievements is that it is the first feature film to contain a complete sequence created entirely with computer-generated graphics.
The Wrath of Khan was released in North America on June 4, 1982. It was a box office success, earning US$97 million worldwide and setting a world record for first-day box office gross. Critical reaction to the film was positive; reviewers highlighted Khan, the film's pacing, and the character interactions as strong elements. Negative reaction focused on weak special effects and some of the acting. The Wrath of Khan is generally considered to be the best film of the entire Star Trek series and is credited with the creation of substantial renewed interest in the franchise.
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 three-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 exposure to high levels of radiation, Spock incapacitates the doctor with a Vulcan nerve pinch and performs a mind meld, telling him to "Remember". Spock restores power to the warp drive and the Enterprise escapes the explosion. 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, where Spock dies of radiation poisoning. A space burial is held in the Enterprises torpedo room and Spock's coffin is shot into orbit around the new planet. The crew leaves to pick up 'Reliants marooned crew from Ceti Alpha V. Spock's coffin, having soft-landed, rests on the Genesis planet's surface.