In the far future on one of the moons of Delta Magna, Delta Three, sits a vast methane and protein collection and manufacturing refinery. The staff of four – the bullying leader Thawn, and his technical support Fenner, Harg, and Dugeen – are in charge of the operation. A green-skinned humanoid native called Mensch, one of the Delta Magnans, serves them. These servile people were once the inhabitants of the main planet but were moved to Delta Three when the Earth Empire identified Delta Magna as commercially valuable; sadly for the green-skinned natives, known as Swampies, this is now also the case on Delta Three. Thawn becomes concerned about the possibility of insurrection when he learns both that the environmentalist group Sons of Earth has taken an interest in Delta Three and that the gun-runner Rohm Dutt is rumoured to be journeying there. Thawn and Fenner head outside the refinery to see if he has arrived, suspecting a mysterious spacecraft which has touched down nearby is Rohm Dutt’s.
The Fourth Doctor and Romana have also arrived on Delta Three, searching for the penultimate segment of The Key to Time. However, the Tracer they are using to locate the segment is giving some very strange readings that makes their quarry difficult to pinpoint. They are ambushed by Swampies and Romana ends up getting taken away with Rohm Dutt and a Swampie patrol, while the Doctor is found by Fenner and Thawn and returned with them to the refinery. There he displays a bewildering familiarity with the methane catalysing process, with the refined protein then shot into space for delivery to Delta Magna. The Doctor is also intrigued by the position of Mensch, whom the refinery workers do not even regard as a properly sentient being. The Doctor slips away to try and find Romana, but she has meanwhile got herself into a degree of trouble. The Swampies have tied her to a rock and are prepared to sacrifice her to Kroll, a giant squid creature that lives beneath the swamps and which they worship as a god. When it appears from the waters, Kroll is a vast squid – or rather a Swampie dressed as one. The Doctor unmasks the fake monster and rescues Romana.
Back at the refinery, Dugeen has detected a vast living creature some two miles wide inside the swamp. The Doctor and Romana have meanwhile found reference to the real Kroll in a Swampie testament, which says the enormous creature ate a previous Swampie High Priest and has made three appearances with a fourth due soon.
Rohm Dutt has supplied the Swampies with weapons but when they are used against Thawn, who is searching the swamps for the Doctor, they are found to be defective and explode whenever fired, resulting in the death of one of the Swampies. Seconds later, a huge tentacle erupts from the water and seizes Mensch, dragging him to his death. In the confusion, Rohm-Dutt calls out to Thawn; his cries go unnoticed however, as everyone's eyes are drawn to the vast squid-like creature that emerges from the swamp, towering above the horizon (as shown in the picture above). Kroll is very real, very large and very hungry. Ranquin attempts to mollify it with prayer, and Kroll disappears beneath the surface of the swamp. Despite Ranquin's belief that Kroll has spared his believers, the monster has simply failed to notice the Swampies, and it is soon drawn to the refinery. One of its tentacles enters a pipeline and soon smashes its way inside, dragging crewmember Harg to his death.
The gunrunner is taken as a prisoner back to the Swampie camp, where the Doctor and Romana arrive and introduce themselves to the tribe and its leader Ranquin. The elder decrees all three "dry-foots" will die by the seventh ritual of Kroll: a cumbersome and painful affair involving the stretching of the victims on creepers and wood that will eventually snap their backs. In fear, Rohm Dutt admits Thawn paid him to sell the faulty weapons to the Swampies as a means to discredit the environmentalist Sons of Earth movement. All three are secured and their punishment begins as a violent storm starts on Delta Three. The Doctor rescues himself, Romana, and Rohm Dutt with "high pitched vocal vibrations", which shatter a window above, allowing the rain to pour in on the vines. This relaxes them enough for the trio to escape, pursued by the Ranquin and his tribe.
The three refinery crew now decide to redirect the orbit shot against Kroll. They note the creature is now on the move towards the Swampie settlement. When it reaches there its first victim is Rohm Dutt. The Doctor deduces that the creature hunts by vibration, and uses this knowledge to keep himself and Romana safe from the tentacles. The enormous Kroll now rises to the surface of the swamp and destroys the Swampie settlement, killing many Swampies before submerging again.
The Doctor and Romana now sneak back into the refinery and are horrified that Thawn calculates the missile strike will destroy the creature and the Swampies. Dugeen is equally appalled, and when he tries to stop the missiles being fired, Thawn kills him. The Doctor, however, is more successful and manages to disconnect the firing mechanism in the rocket silo. Thawn investigates and finds the two culprits, more convinced than ever that they are Sons of Earth spies too. The tables are turned, however, when the Swampies attack the breached refinery and kill Thawn. Ranquin, who has led the assault, believes the deaths of the “dry foots” will help atone to Kroll, but the creature is now above the swamp again and hurling itself against the bulk of the refinery.
While Ranquin fruitlessly prays to Kroll in an effort to stop the attack, the Doctor orders that all the refinery's equipment be activated, in order to try and confuse Kroll. It has the desired effect, and the attack stops. Ranquin refuses to let his faith in Kroll be shaken however, and upon finding one of Kroll's tentacles, begs his god to destroy the "dry foots". Instead, Kroll simply grabs hold of Ranquin and drags him away to his doom. The remaining Swampies realise the creature is beyond appeasement. It is not, however, beyond science. The Doctor has worked out that Kroll has been magnified to giant proportions by a segment of the Key to Time, disguised as a Swampie relic, which the squid creature swallowed along with a previous High Priest. He uses the Tracer to eliminate the giant Kroll and retrieve the fifth segment of the Key.
The Doctor finally saves the refinery from destruction by aborting the automatically scheduled orbit shot, which would have resulted in an explosion, and then tells Fenner, the only survivor of the refinery crew, to use his time wisely until a rescue mission arrives from Delta Magna, and to try to understand the Swampie culture. The Doctor and Romana head back for the TARDIS with another segment of the Key in their possession.