Following the violent explosion of an energy production facility on the Klingon moon of Praxis, the collapse of the Klingon Empire is considered imminent. In 2293, the United Federation of Planets decides that this is the opportunity to finally negotiate a true, lasting peace with the Klingons. Chancellor Gorkon, the leader of the Klingon High Council, immediately heads towards Federation space for the proposed peace conference.
Captain Spock suggests that the U.S.S. Enterprise be Gorkon's escort, forcing Kirk, who still harbors deep resentment for the brutal death of his son at the hands of the Klingons, to meet the Chancellor's ship. The two ships rendezvous peacefully and are proceeding towards the conference when the U.S.S. Enterprise suddenly appears to fire on the Klingon ship and Federation-uniformed men beam to the ship and mortally wound Gorkon. After beaming over to the Klingon ship with Kirk to lend assistance, Dr. McCoy is unable to save Gorkon's life. McCoy is arrested, along with Kirk, for the murder. After a quick trial before the Klingon High Council, the two men are sentenced to imprisonment on a Klingon penal colony. Unknown to the Klingons, however, is that prior to Kirk's beam-out from the Enterprise, a quick-thinking Spock surreptitiously attached a homing patch to the back of Kirk's uniform.
On Rura Penthe, the ice-cold Klingon penal planetoid, Kirk and McCoy meet a Chameloid, Martia, who approaches the pair with an escape plan. The proposed plan, however, turns out to be an elaborate ruse designed to lure Kirk and McCoy into the open, where they can be killed as escapees.
Arriving in the nick of time, the U.S.S. Enterprise tracks Kirk's homing signal and rescues the two officers just before they are killed by the colony's nefarious prison warden. Safely aboard, Kirk and McCoy decide to avoid contact with Starfleet while they work to figure out what happened to the Klingon Chancellor's ship and to identity Gorkon's true killer. They are assisted in this investigation by Captain Hikaru Sulu, commander of the U.S.S. Excelsior.
Meanwhile, Gorkon's daughter, Azetbur, works to continue her father's plan of peace with the Federation, putting her life in serious danger. Learning of this, Kirk and Spock become convinced that there is an organized conspiracy behind the assassination intended to prevent the peace. They set a trap for the suspected conspirators on the U.S.S. Enterprise. Ultimately, Lieutenant Valeris, a promising young Vulcan protege of Spock's is revealed to be one of the leaders of the dissident movement. When Spock performs a Vulcan mind-meld with Valeris, he finds that both Federation and Klingon conspirators are in league against the proposed peace.
The Federation ships proceed to the location of the conference, at Khitomer, but before landing parties are able to beam down both the U.S.S. Enterprise and the U.S.S. Excelsior are attacked by an invisible vessel — one capable of firing while remaining cloaked. The audio transmissions of the vessel identify it as Klingon General Chang's Bird-of-Prey, an unknown prototype. Faced with an unstoppable new form of technology, the two starships sustain considerable damage. Racing against time, equipment on the U.S.S. Enterprise usually used for studying gaseous anomalies is fitted into a photon torpedo. Using some new technology of their own, the U.S.S. Enterprise tracks the cloaked Bird-of-Prey and destroys it.
With the orbiting Klingon threat gone and Valeris apprehended, the U.S.S. Enterprise crew arrives at the peace talks just in time to prevent the planned assassination of the President of the United Federation of Planets. The conference continues, and the first steps are taken towards peace between the Klingon Empire and the Federation.
The U.S.S. Enterprise is recalled by Starfleet Command for decommissioning, but Kirk, in typical fashion, indulges himself and takes the ship out for one last voyage before passing the baton to a new generation of explorers destined "to boldly go where no one has gone before."