The Doctor, Ben, Polly and Jamie, concerned about an image they've seen on the TARDIS scanner of a giant menacing claw, arrive on an unnamed planet in Earth's colonial future. They are greeted by Medok, a half-crazed colonist, who is promptly arrested by Ola, the Chief of Police. The travellers return with Ola to the colony, which appears to be a holiday camp in the midst of a festival. The Doctor remains sceptical of life at the camp itself, unnerved by the seemingly fake nature of the society, and unconvinced by the promises of the Colony Pilot and the well wishes of the mysterious Colony Controller, who appears on a television screen to welcome the new guests to the colony.

Medok is paraded before the colonists as an example of deviation for losing his joy. He tries to warn the colonists of horrible creatures, which infest the colony at night with their hideous claws. The Doctor frees him from the cell in which he has been placed, but Medok runs away from the Doctor, who is charged by the Pilot and Ola with abetting a criminal. He is released on condition that he and his friends do some hard labour in the nearby mine, where a gas is extracted which is poisonous to humans yet is supposedly vital to them.

The Doctor slips away and finds Medok, who explains that the colony is infested with giant insects, which appear at night. When others have seen them they have been hospitalised and brainwashed, but Medok has managed to escape this fate. The night curfew begins and the other time-travellers retire to their rest quarters. The Doctor and Medok use the opportunity to investigate, and find the giant crab-like Macra roaming the colony.

The pair are soon captured and brought before the Pilot, but the Doctor is released when Medok claims the Doctor was only trying to get Medok to turn himself in. Later, the Pilot is told by the Controller to hypnotize the four new arrivals so that they begin to think like the others in the colony. Polly and Jamie resist the adaptation process, but Ben succumbs, becoming an enthusiastic worker for the colony’s mines. He summons Ola, who arrests the Doctor and Jamie for tampering with the hypnosis equipment.

When Polly does some investigating she is captured by the Macra, but her screams of peril are strong enough to break Ben’s conditioning and he rescues her. When they are reunited with the Doctor and Jamie their story is enough to persuade the Pilot that the four are a dangerous influence in the Colony and must be controlled. He calls on Control to restore order but when the screen is illuminated it is not the handsome young Controller who speaks, but an aged and terrified old man who is dragged away by a giant claw.

The Pilot is briefly disturbed but regains his composure and has the time travellers arrested once more – though Ben’s reconditioning has reasserted itself and he is allowed to go free.

The Doctor, Polly and Jamie are sentenced to work as hard labour on the Danger Gang in the most treacherous part of the mine. Medok has also been confined to this area, his hospitalised processing having failed. He warns that the mortality rate is high in this part of the mine. The Doctor is left topside while the others venture into the deeper workings of the mine. Jamie and Medok manage to escape, but the latter is soon seized by a Macra claw and dragged away to his death. Jamie comes face to face with a giant Macra, which seems to be sleeping until there is a burst of the deadly gas, which rejuvenates the creature. Other Macra soon appear, and the creatures advance on Jamie.

Back on the surface the Doctor uses his guile to sow seeds of doubt regarding the truth of the planet in the minds of the colonists and of Ben, whose conditioning is weakening. The Doctor has worked out the gas flow seems to be the key to the situation and cleverly reverses the gas flow from the mine control area. Polly has reached the surface, and the Doctor calculates that he can buy Jamie time to escape from the mine as well. The improved oxygen flow weakens the Macra, enabling Jamie to evade them and escape.

The Doctor and Polly invade the control area and find it over-run with Macra. The Doctor realizes that the deadly gas is vital to the Macra and that the entire colony is a front to enable gas production to take place, with the human colonists brainwashed into serving the Macra while believing they are obeying Control.

Security chief Ola demands that the travellers be punished for disobeying Control, but the Doctor persuades the Pilot to accompany him to the Control centre. The Pilot sees the Macra for himself, and his conditioning is broken. In a last gamble the voice of Control has Ola place the Doctor, the Pilot, Polly and Jamie in an area of the mine where a mixture of combustible gasses will shortly explode. Ben, who has finally broken his conditioning, frees them, and some manipulation of the gas pipes sends the combustible mixture to the Control Centre. When the gas explodes, the Macra are all killed. As the colony becomes a happy holiday camp once more, the time travellers make their exit.