While travelling through an ion storm to take readings, the Enterprise picks up a distress signal. The signal is from a colony ship crewed by a race the Federation has had only the briefest of prior contact with: the Cornuvians. The Cornuvians are red-skinned, with small vestigial horns, giving them a devilish appearance. Their ship, the Paluk-Ta, suffered a direct hit from an asteroid, destroying its warp nacelle and killing the bridge crew; they have impulse engines, but the chief engineer was badly wounded and the colonists don’t know how to run the ship.
Because the ion storm requires them to keep the shields up, preventing them from using the transporters, Kirk decides to take the shuttle Galileo over to the Paluk-Ta with an away team consisting of Sulu, to helm the colony ship, Scotty, to repair the impulse engines, and Chekov, to speak in a funny accent. As they approach the Paluk-Ta, a near miss from a fast asteroid causes the shuttle to crash in the Paluk-Ta’s landing bay. Nobody is injured, but the Galileo can’t take off again, nor can another shuttle from the Enterprise land; for better or worse their fates are now entwined with the colonists aboard the Paluk-Ta.
They contact Spock, and are informed that the Enterprise’s sensors are detecting multiple energy sources in the asteroid belt, and there was a flare of energy not caused by the ion storm shortly before the near collision of the rogue asteroid with the Galileo.
Kirk meets the head of the colonists, a striking Cornuvian woman named Aman-Te. The Enterprise crew notice that all the officers they meet are women, though there seem to be male crewmembers and file away the information under “suspicious.” Aman Te attempts to negotiate the price of their rescue with Kirk, but he waves it away, citing Star Fleet policy helping ships in distress. Aman-Te is at first upset, but then aquiesces.
Meanwhile Scotty has figured out the controls in the auxiliary bridge of the Paluk-Ta, and brought the impulse engines online. At this point Chekov, manning the scanners, notices increased activity in the asteroid belt, and several asteroids start accelerating towards the Paluk-Ta!
(break for commercial)
Several asteroids begin accelerating towards the Paluk-Ta. Kirk orders evasive maneuvers, and Sulu wrestles with the controls. The bridge crew are flung about, but they manage to avoid any hits. Kirk orders the Enterprise to approach, to fend off the asteroids with photon torpedoes, but the Enterprise finds itself the target of several new asteroids, too large to be deflected by torpedoes and Kirk orders them to withdraw to a safe distance.
Chekov reports more energy signatures in the asteroid belt, and scans indicate that there are mechanical devices active, but no life forms. With further scans and some leaps of intuition, the crew deduce that the mechanical signatures belong to robot factories, probably abandoned mining installations and they are producing more and more robots in response to the new activity in the system. Scotty realizes that the mining robots are configuring into magnetic accelerators and using them to toss nickel-iron asteroids at the intruders…essentially cobbling together huge rail guns, and as the factories expand they’ll be producing more and more of them.
Kirk orders Sulu to take the Paluk-Ta into the shadow of the one inhabitable planet of the system and hold it in orbit there, where it will provide cover from the enemy rail guns. Sulu manages to get the great ship in position, but it wasn’t built with that sort of manuevering in mind, and the impulse engines are insufficient to hold it in a geostationary orbit close enough to the planet to provide cover. In a few minutes they are either going to once again be exposed, or the ship will spiral out of control and crash into the planet below!
Faced with the choice of either being raked by fire from the self-assembling rail guns or crashing, Kirk decides that they will have to land the Paluk-Ta on the planet’s surface, even though once it does so it will never be able to take off again. The colonists will have to live in this system instead of their intended destination. Informing Aman-Te of his decision, he is surprised when she and her crew offer no objection despite being visibly unhappy with the idea.
Sulu manages to bring the Paluk-Ta down safely, and they are safe from the robots for the time being. Kirk is in the process of seducing Aman-Te to learn more about their situation when Spock communicates from the Enterprise that the ion storm is abating and they can bring the Enterprise into orbit and beam the away team back.
After returning to the Enterprise, they conceive the notion of beaming aboard one of the robot mining droids for examination. They prove to be quite primitive modular systems, with each module having very limited programming; in absense of instructions from their creators, they’re following programs to maintain themselves and defend the mining claim from intruders. Scotty manages to reprogram the droid to go into a maintenance-only, non-guard mode, and seek out other droids reprogram them to go into the same mode then seek out and reprogram other droids. They re-release the droid and in a few hours the rail guns have disassembled themselves and the mining factories gone quiet.
Kirk contacts Aman-Te and the colonists, and promises them that he will bring their situation to the attention of Star Fleet and their home world as soon as possible, to see if anything can be done. In the mean time, at least they are safe, and have a habitable planet to colonize…and an entire set of asteroid mining installations ready to serve them!