On the planet Centaurus, the planetary capital of New Athens has been annihilated by a terrorist antimatter bomb. Millions are dead; because of a computer malfunction, the planetary defense system is preventing any rescue ships from approaching the planet. No subspace communication is possible, and traditional speed-of-light radio is blanketed with heavy static. Despite an emergency do-not-approach warning (known as Code 7-10, which went unheard), the first three relief ships, carrying hundreds of medical personnel, are destroyed by ground-to-air missiles as they assumed standard orbit. The USS Enterprise has been sent to assess the situation and offer what relief they can, but they are in need of help themselves as the ship is falling apart around them due to an unexplainable massive computer malfunction of their own; the transporter is made inoperable by the antimatter's residual tachyon radiation.
The tragedy has a personal touch as well-- Dr. McCoy's daughter Joanna is among the missing, as well as friends and relatives of other crewmembers. While Spock attempts to disable the planetary defense computers, Captain Kirk, Mr. Sulu and attorney Samuel T. Cogley become involved with the terrorists when the terrorist leader contacts Cogley and ask him to represent them in Federation court. Despite his personal feelings, Kirk is determined that the terrorists will get a fair trial under Federation jurisdiction, but certain individuals in the patchwork government are equally determined that the terrorists will not leave Centaurus alive. While the surviving Centauran government engages in an all-out search for Kirk and party, Kirk learns that three more antimatter bombs are somewhere on the planet, and is forced to take refuge in the one place he cherishes most - the little cabin he had built in Garrovick Valley, on the river Farragut.
On seeing the names 'Garrovick' and 'Farragut' on a map, Commander Spock correctly surmises the position of Kirk's buen retiro, and a scan from orbit reveals an army of government hovercars flitting around the cabin. By leveraging the Enterprise's crippled warp drive's controls, engineer Montgomery Scott and his second-in-command succeed in enabling the Enterprise to enter the atmosphere. The government hit squad's weapons are no match for a starship's phasers set on stun; the captured terrorists are taken in custody, but the secret of cheap antimatter synthesis is lost: its creator was the suicide bomber who set the first weapon off.
In the epilogue, Spock traces the computer malfunction to a quantum black hole accidentally forming, against all odds, within the Enterprise in warp, drilling a hole straight through a good part of the computer memory banks.