On a distant planet, a huge sandminer vehicle, Storm Mine 4, is slowly scraping the surface of a vast, barren desert in search of precious minerals. The sandminer is manned by nine humans and numerous robots - black 'Dums' that cannot speak, pale green 'Vocs', and a silver 'Super Voc' which controls all the 'Dums' and 'Vocs'. The robots conduct a routine scan of the area and locate a large sandstorm, which the humans decide to pursue, as the storm will bring heavier minerals to the surface. One of the humans, a meteorologist called Chub, goes to collect an instrument package to place into his weather balloon to study the storm. However, he is later found strangled.
At about this time, the TARDIS materialises in one of the scoops. After the Doctor and Leela emerge from the TARDIS, it is removed by a large mechanical arm as it is blocking the scoop. Later, the Doctor and Leela are brought out of the scoop by two robots and locked in a room. The Doctor uses his sonic screwdriver to unlock the door, and goes in search of the TARDIS, while Leela finds Chub's body being taken away by some robots.
The human crew suspects the two time travellers of murdering Chub, and tensions increase when it is found that they have left the room in which they were locked. By the time they are both recaptured, the Doctor has found a second dead man (Kerril), and Leela has found both a third dead man (Cass) and a 'Dum' robot which can secretly speak. Commander Uvanov orders them to be locked up in the robot storage bay, on suspicion of killing all three humans.
One of the humans, Poul, believes the Doctor and Leela to be innocent, so he frees them and shows them where Chub was murdered. There, the Doctor convinces Poul that a robot may have killed the mineralogist. While this is happening, a women named Zilda is murdered, and Poul - sent to the room to investigate Zilda's accusations of murder against Commander Uvanov over a tannoy system - finds the Commander standing over Zilda's body and has him confined to his quarters for murdering Zilda.
The sandminer's engines begin to run out of control, threatening the vehicle with destruction. It is found that Borg, the human responsible for controlling power to the motors, has been viciously strangled, and the controls have been sabotaged. The Doctor saves the miner by cutting off the power to the motors, while a man named Dask repairs the damaged controls so that the miner can continue on its way.
The Doctor goes to see the 'Dum' robot that Leela claimed could speak, D84. The robot reveals that it and Poul are undercover agents for the mining company, who were placed on board the miner as a precaution to threats of a robot revolution by a scientist called Taren Capel, who was raised by robots. D84 itself is unique in the fact that it can function autonomously from Super Voc SV7's commands, and appears to possess a high level of logical reasoning. The Doctor and D84 search the miner for proof that Taren Capel is on board, and find a secret workshop where the robots' programming has been changed to enable them to kill humans. The Doctor arranges for all the remaining humans to go to the command deck.
Dask shuts down all of the robots whose programming has not been changed, leaving just the killer robots and D84 operational. Dask is later revealed to be the mad scientist Taren Capel, intent on 'releasing [his] 'brothers' (the robots) from bondage to human dross' and 'programming them with an ambition to rule the world'. Taren Capel orders his modified robots to destroy the remaining humans and the Doctor and Leela. Leela shows the Doctor a damaged robot in the storage bay with its hand covered in blood - which the Doctor reasons is Borg's, guessing that Borg sabotaged the engine controls in a suicidal attempt to destroy the miner and all the killer robots on board. The Doctor dismantles the damaged robot and creates a final deactivator - a device that will destroy any still functioning robots at close range. The Doctor hides Leela in Taren's workshop with a canister of helium gas, telling her to release it slowly when Taren comes in. The Doctor hopes that this will change Taren's voice, so his robots - unable to recognise him - won't obey his orders.
Taren arrives and damages D84, but the robot is able to activate the Doctor's device to destroy a killer robot, knowingly sacrificing itself in the process. Leela releases the helium gas, causing Taren's voice to become high-pitched and squeaky, and Taren is killed by SV7 when it fails to identify his voice. The Doctor then destroys SV7 with a laser probe.
The robot threat over, and a rescue ship coming to collect the surviving humans, the Doctor and Leela return to the TARDIS and leave the sandminer.