Stardate 3451.9: The Enterprise is approaching the Malurian system in response to a distress signal, but detect no sign of life. There's no indication of system-wide catastrophe or interstellar war, and no disease that could have wiped out the population since they contacted the Federation team a week ago. An object approaches them at ultra-warp speed and hits them with the impact of 90 photon torpedoes. They can only take four more such attacks. The object attacks again and they manage to return fire but have no effect.
Kirk hails it, identifying himself, and the object stops its attack. Spock determines it's only one meter large and they assume it's a spaceship. The attacker probes their databases then identifies itself as Nomad and asks them to leave their ship. They offer to beam it aboard and it agrees, and they find the object is a mechanical device that asks for their point of origin. It's protected by a screen against scanning and they offer to show it their system charts to determine point of origin. They take it to an auxiliary control room where it recognizes Earth and believes Kirk is it creator. It says that it wiped out all unstable biological units as part of its program of sterilization. When Nomad questions Kirk's concerns, Spock confirms that Kirk is testing Nomad's data banks. It claims it's been injured and they step outside where Spock determines that a Nomad probe was damaged centuries ago and reported missing, but it was on a peaceful mission.
While Nomad checks the data banks, Uhura starts singing on the bridge and it hears her and goes up the bridge. Meanwhile, Kirk reviews the computers and determines that Jackson Roykirk created Nomad and it believes Kirk is its creator due to its damaged memory banks. It was originally supposed to seek out life forms, but now it is seeking out perfect life forms… and destroying any that are less then perfect.
Nomad arrives on the bridge and tries to determine what "music" is. When Uhura is unable to respond, it fires a beam at her head and when Scotty interferes, it blasts him back, dead. Kirk is furious until Nomad offers to repair "the unit." Kirk agrees and Changeling brings Scotty back to life after scanning the ship's anatomy tapes, then goes to Sickbay and restores Scotty to life. Kirk tells it to "repair" Uhura but Nomad is incapable to do so, since it wiped her knowledge. They conclude they can reeducate her, and Kirk has two security guards escort it to the brig.
Spock tries to run an analysis but Nomad maintains its screens. Kirk orders Nomad to allow Spock access but it isn't sufficient. Spock undertakes the Vulcan Mind Meld and determines it was merged with another alien probe, Tan Ru. Tan Ru was a probe designed to seek out and sterilize soil samples. When the damaged Nomad encountered it, it took on some of its programming and determined to seek out and sterilize imperfect life forms. Only the fact it thinks Kirk is its creator has kept them alive.
Nomad breaks through the force field and kills the guards, then goes to Engineering and starts reprogramming the "primitive" matter/anti-matter propulsion system. The ship goes into ultra-warp drive until Kirk orders it to stop its "repairs." When he realizes the security guards are dead, Kirk snaps and points out that an imperfect biological form created Nomad. It considers that and reluctantly obeys Kirk's orders to go back to the brig while it re-evaluates its mission before it returns to "launch point." They realize that it can now find its way back to Earth, and will destroy all imperfect life forms when it arrives there.
Nomad moves away from the guards halfway to the brig and destroys them when they open fire. It goes to Sickbay and Kirk and Spock arrives as it emerges, and ignores Kirk's orders. McCoy reveals that Nomad examined Kirk's medical history and they figure it has determined Kirk is an imperfect biological unit. Nomad goes to Engineering and shuts down the ship's life support systems. Kirk orders Scotty to bring anti-gravs and meet him in Engineering, then goes to confront Nomad. He points out an imperfect biological unit created it but Nomad refuses to consider his words. Kirk pushes the fact that he's Nomad's creator and it agrees. Kirk then drives the point home, noting that it is mistaken in identifying him and has made an error. Further, it failed to discover the mistake, then failed to sterilize itself, compounding the mistake. It tries to correlate the error and they use the anti-gravs to move it to the transporter. Kirk tells it to execute its prime function and they beam it out into space. Once away, it self-destructs.
Later on the bridge, McCoy reports that Uhura is recovering and Spock laments the waste. Kirk is left to joke about what kind of doctor his "son" would have made.