The Enterprise responds to a distress call in the L370 system and discovers that something has destroyed almost every planet in the system. They also find its sister ship the U.S.S. Constellation, which has been badly damaged. The captain of the Constellation, Commodore Matt Decker, says that his crew evacuated to one of the pulverized planets and was lost, and the attacker was a giant robot "doomsday machine." Kirk is stranded on the Constellation when the doomsday machine attacks again, and the shell-shocked Decker tries to take command of the Enterprise to lead a futile attack.