The USS
Enterprise, following a trail of mysteriously destroyed star systems, picks up the automated distress beacon of one of
Enterprise sister ships, the USS
Constellation. Upon arrival, the
Constellation is found heavily damaged and drifting in space; Captain
Kirk, Chief Medical Officer
Dr. McCoy, Chief Engineer
Scott, and a damage-control team transport to the ship to evaluate her. Once there, they discover the only member of the crew still aboard is the ship's commander,
Commodore Matt Decker, who is nearly
catatonic and suffering from severe mental shock. After McCoy injects him with a stimulant, Decker explains that his crew and he had discovered a giant machine, miles long, that used beams of
antiprotons to tear planets apart, consuming the rubble for fuel. The attack by
Constellation on the machine was ineffective, and the ship suffered heavy damage. Decker evacuated his crew to a nearby planet,
remaining aboard the Constellation until last; however, the machine subsequently destroyed the ship's transporter, and then the planet, killing the entire crew. Kirk theorizes that the machine is an ancient
doomsday machine, which must be stopped before it reaches more populated sectors of the galaxy. McCoy and Decker transport to
Enterprise, which has taken
Constellation in tow, while Scott's damage-control team attempts repairs on
Constellation damaged impulse engines, weapons, and shields. Kirk attends to
Constellation nonfunctional viewscreen, which aside from communications from
Enterprise, will be his only means of monitoring events outside the ship. ''Enterprise's
first officer, Spock, informs Kirk of the sudden appearance of the planet killer, which begins to pursue Enterprise''. As Kirk's boarding party prepares to beam back aboard, the machine attacks
Enterprise, damaging the transporter and disrupting communications. Decker, now the senior officer on board
Enterprise, assumes command and orders a phaser attack on the machine; this fails, as the machine's hull is of solid
neutronium. Despite Spock's objections, Decker refuses to retreat, and the planet killer captures the
Enterprise in a tractor beam, drawing it into its maw. Completing his repair of
Constellation viewscreen, Kirk is shocked to see
Enterprise engaging the planet killer. Scott has managed to repair
Constellation impulse engines and one of her phaser banks, so Kirk uses the crippled ship to approach and fire at the planet killer, distracting it long enough for
Enterprise to escape its tractor beam. After repairing the transporter and re-establishing voice communications,
Enterprise retreats to a safe distance. Spock relieves Decker of command on Kirk's authority, and Decker is escorted to sickbay. However, Decker overpowers his security escort and steals a
shuttlecraft. Overcome with
survivor's guilt over the loss of his crew, Decker informs Spock he is flying the shuttlecraft straight into the maw of the machine. Kirk begs Decker to return to
Enterprise, but Decker does not deviate from his course and flies into the machine, where he dies. Lt.
Sulu reports that the shuttlecraft explosion has reduced the planet killer's power output by a small amount. Realizing that this may have been Decker's intention, and hoping that a starship would do much more damage, Kirk comes up with a plan to explode
Constellation inside the planet killer. Over Spock's objections, Kirk insists on piloting the damaged starship himself, and Scott rigs the impulse engines to explode with a 30-second delay before detonation, warning his captain that once the timer is enabled, no way remains to abort it. With the rest of the boarding party transported back to
Enterprise, Kirk aims
Constellation at the maw of the planet killer, triggers the timer, and orders
Enterprise to beam him aboard. The transporter malfunctions, and Scott races to set it right with advice from Spock. With virtually no time to spare, Kirk is safely beamed aboard
Enterprise as
Constellation explodes inside the planet killer, destroying the machine's power system and leaving it permanently dead in space. As the
Enterprise departs, Kirk and Spock speculate that other doomsday machines could be out there. ==Production==