Three Time Lords meet at an observatory and discuss the theft of confidential files relating to "the Doomsday Weapon." They begrudgingly realise that only one man can help them — and the Doctor, accompanied by Jo, is temporarily released from his exile and sent in the TARDIS to the desert planet of Uxarieus in the twenty fifth century. There he finds an outpost of human colonists living as farmers. The colony is not a success — the land seems unusually poor and recently they are being besieged by representatives of rapacious mining corporations, and more recently, ferocious reptiles. The colony's governor, Robert Ashe, makes them welcome, and explains the colonists fled a year ago to the planet to escape the overcrowding and pollution on Earth.
Two colonists die in a reptile attack that night, and the next morning a man named Norton arrives at the settlement, claiming that he is from another colony that was wiped out by the reptiles. While the Doctor is investigating the dome of the dead colonists he is surprised by a mining robot controlled by Caldwell, a mineralogist for the IMC. Caldwell invites the Doctor to talk to his bosses and hear their side of the story. His superior, Dent, is a ruthless mining engineer, who has been using the mining robot to scare and now kill the colonists - something which Caldwell finds repellent. Dent knows the planet is rich in rare minerals and wants it for IMC and his greedy troops agree that this should be done at any cost.
The original inhabitants of the planet, known to the colonists as primitives, have a truce with the colonists - but this is tested when Norton kills the colony's scientist and blames it on a primitive, whom he insists are hostile. The Doctor meanwhile returns to the central dome of the colonists, having evaded an IMC attempt to kill him, and explains to Ashe that the miners are behind the deaths. An Adjudicator from Earth is sent for to deal with the complex claims over the planet - and when he arrives it turns out to be the Master. In this alias he determines that the mining company's claim to the planet is stronger.
The Doctor and Jo have meanwhile ventured to the primitive city. From images on cave walls they interpret it was once home to an advanced civilisation that degraded over time. In the heart of the city, in a room filled with massive machines and a glowing hatch, they encounter a diminutive alien known as the Guardian. It warns them that intruding into the city is punishable by death, and lets them go, but warns them not to return.
The Master's adjudication is heard by a returning Doctor and Jo. Still in the Adjudicator's guise he tells Ashe that an appeal will fail unless there are special circumstances, such as historical interest and is intrigued when Ashe tells him about the primitive city. By this ploy he finds out more about the planet and the primitive city while Ashe is drawn away from the Doctor, who begins to lose his credibility with the colonists. The Master then manipulates the Doctor into accompanying him to the primitive city.
The situation between colonists and miners has meanwhile reached flashpoint with a pitched battle between them. Dent and his forces triumph and he stages a false trial of Ashe and Winton, the most rebellious of the colonists, sentencing them to death but commuting the sentence if all the colonists agree to leave the planet in their damaged old colony ship which first brought them to Uxarieus.
Inside the city, the Master tells the Doctor that the primitives were once an advanced civilisation. Before their civilisation fell apart, they built a super-weapon that was never used - and he wants to claim this weapon for himself. The room with the machinery in the city is the heart of a weapon; so powerful that the Crab Nebula was created during a test firing. The Doctor rejects the Master's overture to help him rule the galaxy using the weapon, stating that absolute power is evil and corrupting. The Guardian appears, demanding an explanation for the intrusion. The Master explains that he's come to restore their civilisation to its former glory. The Doctor argues against him, and the Guardian recalls that the weapon led his race to decay, and its radiation is ruining the planet. It instructs the Doctor to activate the self-destruct, which he does. The city begins to crumble, and the Guardian tells them they must leave before it is too late. While the Doctor and the Master flee the decaying city, they find Caldwell and Jo, and the four get out before the city explodes.
The colonists' ship has meanwhile exploded on take-off as Ashe predicted it would. However, the colony leader was the only one to die. He piloted the ship alone to save his people. Winton and the colonists now emerge from hiding and kill or overpower the IMC men, with Caldwell having switched sides to support the colonists. Amid the confusion, the Master manages to make his escape.
With the battle over, the Doctor explains that the radiation from the weapon was what was killing their crops but this limiting factor has now been removed. He and Jo return to the TARDIS, which returns to UNIT Headquarters mere seconds after it left. Having accomplished what the Time Lords intended, the Doctor is once again trapped on Earth.