As a Klingon moon, Praxis, explodes without warning, the starship USS Excelsior, commanded by Captain Hikaru Sulu, is struck by the shock wave and its crew discovers that much of the moon has been obliterated. The loss of their key energy production facility and the destruction of the Klingon homeworld’s ozone layer throws the Klingon Empire into turmoil. No longer able to maintain a hostile footing, the Klingons sue for peace with their longstanding enemy, the United Federation of Planets. Accepting the proposal before the Klingons revert to a more belligerent approach, Starfleet sends the USS Enterprise-A to meet with the Klingon Chancellor, Gorkon, and escort him to negotiations on Earth. Enterprise ’s captain, James T. Kirk, whose son David was murdered by Klingons years earlier, opposes the negotiations and resents his assignment.
After a rendezvous between Enterprise and Gorkon’s battlecruiser they continue towards Earth, with the crews sharing a tense meal aboard Enterprise. Later that night, Enterprise appears to fire on the Klingon ship with a pair of photon torpedoes, disabling the artificial gravity aboard the Klingon vessel. During the confusion, two figures wearing Starfleet suits and gravity boots beam aboard the Klingon ship and grievously wound Gorkon before beaming away. Kirk surrenders to avoid a fight, and beams aboard the Klingon ship with Doctor Leonard McCoy to attempt to save Gorkon’s life. The chancellor dies, and Gorkon’s chief of staff, General Chang, puts Kirk and McCoy on trial for his assassination. The pair are found guilty and sentenced to life imprisonment on the frozen asteroid Rura Penthe. Gorkon’s daughter, Azetbur, becomes the new chancellor, and continues diplomatic negotiations; for reasons of security, the conference is relocated and the new location is kept secret. While several senior Starfleet officers want to rescue Kirk and McCoy, the Federation president refuses to risk full-scale war. Azetbur likewise refuses to invade Federation space, stating that only Kirk and McCoy will pay for her father’s death.
Kirk and McCoy arrive at the Rura Penthe mines and are befriended by a shapeshifter named Martia, who offers them an escape route; in reality, it is a ruse to make their arranged deaths appear accidental. Once her betrayal is revealed, Martia transforms into Kirk’s double and fights him, but she is killed by the prison guards to silence any witnesses. Just before the prison warden reveals who set them up, Kirk and McCoy are beamed aboard Enterprise by Captain Spock, who had assumed command and undertaken an investigation in Kirk’s absence. Determining that Enterprise did not fire the torpedoes but that the assassins are still aboard, the crew begins looking for them. The two assassins are found dead, but Kirk and Spock trick their accomplice into believing they are still alive. When the culprit arrives in Sickbay to finish off the assassins, Kirk and Spock discover that the killer is Spock’s protégé, Valeris. To discover the identity of the conspirators, Spock initiates a forced mind-meld, and learns that a group of Federation, Klingon, and Romulan officers plotted to sabotage the peace talks, and Chang is one of the conspirators. The torpedoes that struck Gorkon’s cruiser came from a prototype Bird of Prey that can fire while cloaked, and hovered just below Enterprise at the time of the assassination.
The crew contacts Sulu, who informs them the conference is being held at Camp Khitomer. Both ships head for the talks at maximum warp. As Enterprise nears the planet, Chang’s cloaked Bird of Prey moves to intercept. With Enterprise unable to track his ship’s position, Chang inflicts severe damage on Enterprise and then Excelsior. At Uhura’s suggestion, Spock and McCoy modify a photon torpedo to home in on the exhaust emissions of Chang’s vessel, using equipment originally intended to study gaseous anomalies. The torpedo impact reveals Chang’s location, and Enterprise and Excelsior destroy the Bird of Prey in a flurry of torpedoes. Crew from both ships beam to the conference and halt an attempt on the Federation president’s life. Kirk pleads for those present to continue the peace process, and (answering Chancellor Azetbur’s questions about the assassination attempts) replies, “Some people think the future means the end of history. Well, we haven’t run out of history quite yet. Your father called the future ‘the undiscovered country’. People can be very frightened of change.” Azetbur says Kirk has restored her father’s faith; Kirk responds that she has restored that of his son. Having saved the peace talks, Enterprise is ordered back to Earth by Starfleet Command to be decommissioned, but the crew decide to take their time on the return voyage. As Enterprise cruises towards a nearby star, Kirk proclaims that though this mission is the final cruise of Enterprise under his command, others will continue their voyages.