The TARDIS detects signs of temporal disturbance on the planet Hirath in the Thannos system, and the Doctor materializes on the planet’s moonbase to investigate. He and Sam emerge to find themselves in a monitoring station run by Temporal Commercial Concerns, in an area of the base which isn’t marked on the official maps. Hirath is covered by a patchwork of discrete time fields, and since only TCC knows the safe routes through, they have profited by leasing the zones out to different interests. If anything disrupts the delicate balance between the zones, however, the resulting reaction could tear apart the Vortex and destroy most of the galaxy.
The Doctor and Sam split up to look for someone in charge, but there is only a skeleton crew on duty and the supervisor, Vost, is nowhere to be found. Most of the equipment on the moonbase has been malfunctioning recently, and the incompetent Vasid, incapable of handling the stress, has turned to the addictive narcomilk as an escape. The drink increases his paranoia until he becomes convinced that his co-worker, Anstaar, has murdered Vost and hidden the body. Vasid lures Anstaar into the control room, overpowers her and transmats her to the surface of Hirath, and does the same to Sam when she stumbles across him. The Doctor arrives too late to stop him, just as a pulse of energy blazes through the moonbase. The base is in fact an alien spacecraft which TCC has appropriated, and the programming conflict between the alien computers and TCC’s bolted-on equipment has finally reached the critical point. Vasid’s use of the transmat has drained the last power from the systems, and soon the computers which are regulating the time fields on Hirath will shut down, causing the catastrophe which the Doctor had feared. And as if that wasn’t enough, an alien spacecraft is approaching the base, and the Doctor believes that the final energy pulse was a deliberate signal; the base’s real owners are back, and it has called out to them for help.
Sam has arrived in a barren desert colony where political prisoners from the Outer Worlds have been exiled for life. A freedom fighter named Felbaac had purchased the safe route to the colony, intending to rescue the prisoners, form an army and overthrow the rule of the Inner Worlds and their justice force, the K’Arme. But his leadership skills leave much to be desired, the prisoners are largely disillusioned and hopeless after spending twenty years in the desert, and Felbaac’s ship is now aged and useless, having passed through a fluctuating time field on the way down. As the malfunctioning moonbase computers cause the day to stretch out endlessly, a K’Arme squadron led by Commissioner Sangton arrives on the planet in search of Felbaac. Felbaac reveals that he had lured them here deliberately as part of his plan, and since Sangton has never met Felbaac in person, Felbaac convinces Sam to pretend to be him as a distraction while Felbaac carries out the rest of his plan. Sam agrees to do so.
The Doctor is forced to draw power out of the sealed area of the base to keep the systems on-line, despite the risk that this might attract attention from whatever is in there. Vasid, meanwhile, breaks into Vost’s quarters, and learns that he was involved in the double-dealing between Felbaac and Sangton. Unwilling to get involved, Vasid flees and tries to hide in the corridors of the base, but is caught and killed by the Kusks, monstrous creatures from the sealed area of the base. The Kusks had already found and killed Vost, and have now emerged to investigate the power drain caused by the Doctor. The Doctor is forced to transmat himself to Hirath to escape from the Kusks, hoping that he will end up in the same place as Sam.
Sangton isn’t fooled by Sam’s deception, and threatens to kill every man in the colony unless Sam beats Felbaac’s two known associates, Tanhith and Yost, to death. While Sangton is distracted, however, Felbaac overpowers his pilot, steals the safe path co-ordinates and returns, to hold Sangton at gunpoint while the refugees evacuate into Sangton’s ship. Sangton threatens Sam’s life, but Felbaac refuses to surrender -- and when Tanhith tries to rescue her, Felbaac panics and shoots him in an attempt to regain authority. The other prisoners try to seize the gun, and in the resulting struggle he kills another of the prisoners -- and the others, finally provoked into rising up in anger, turn on the K’Arme.
The Doctor materializes near Anstaar in a zone which has been leased out for use as an asylum. Most of the staff appear to have deserted, apart from a few who, like the inmates, are being used as subjects to test experimental new biotechnology. When the Doctor locates the assistant director’s notes, he learns that the staff abandoned the asylum after an accident during construction of a new extension. Shortly afterwards, another interest group began conducting experiments upon those who remained -- with TCC’s tacit approval. Meanwhile, the Kusk ship docks with the moonbase, and the Kusks aboard are reunited with their lost brethren, who have been hibernating for over a century. The Prize they seek is still on the planet’s surface, and the computers in the moonbase, which were meant to repair it, have instead been overwhelmed by the information from it and are malfunctioning. The Kusks decide to send parties to each time zone where the temporal distortion is strongest, with orders to kill any aliens on sight.
While searching for the area where the accident occurred, the Doctor and Anstaar find a forest of time trees, and the Doctor realizes that TCC must be selling them; to the Tractites at least, and perhaps to others. With the help of Nashaad, a childlike man with bionic legs, they locate the Kusk’s Prize, a malfunctioning time-space probe which the Doctor realizes is the source of the temporal distortion that has transformed Hirath. The Kusks, meanwhile, kill their way through the inmates to reach their Prize. The Kusks’ homeworld was all but destroyed in the crossfire of an intergalactic war, and the Kusks have become unprincipled warriors seeking to meet the Universe from a position of strength. The probe was designed to locate the weaknesses of local species by studying their history, so the Kusks could easily conquer them; but it has malfunctioned, and the recovery team sent to collect it was forced to hibernate while their computer attempted to solve the problem. Instead, the computer also began to malfunction, at which point TCC stumbled across the situation and took advantage of it. Now a second expedition has arrived, and at last the Kusks are ready to seize the Prize and the valuable strategic data within.
Another party of Kusks arrives in the penal colony, where they encounter and kill Sangton as he flees from the rebelling prisoners. Yost, meanwhile, convinces the other prisoners to recognize Felbaac’s authority again, and Felbaac calls down an orbiting ship containing K’Arme sympathisers whom he has kidnapped. He intends to leave them stranded in the colony while the prisoners escape, so the K’Arme’s long-range sensors don’t notice that the colony has suddenly been abandoned. But due to the continued breakdown of the moonbase computers, the supposed safe route is no longer safe, and when the ship lands Felbaac finds that the occupants have aged to dust. Before he can react, the Kusks arrive and start killing everyone, and the panic-stricken Felbaac and Yost flee in the cargo ship with only two survivors for their army. But as they try to escape from Hirath, the ship passes through the shifting time zones and they all age to death.
The Doctor bargains for his and his friends’ lives by threatening to destroy the Prize, and he, Anstaar and Hirath manage to negotiate the geological and temporal upheavals which are destroying Hirath. A Kusk is waiting for them at the transmat, and Nashaad is killed fighting it off while Anstaar breaks her leg. Anstaar remains on the planet while the Doctor transmats himself to the moonbase, where he offers to help the Kusk race if they turn away from their warlike, destructive path. The Leader rejects his offer and seizes the Prize, the circuitry which will enable the Kusks to download the probe’s data. Before they can kill the Doctor, however, Felbaac’s pilotless ship crashes into the moonbase, destroying much of it. Assuming the Doctor to be dead, the Kusks begin clearing a path back to their ship, leaving one technician behind to begin the download. The Doctor recovers, and as the technician attacks him, Anstaar transmats herself up from Hirath to avoid two approaching Kusks. Her arrival distracts the technician, and the Doctor throws it into the transmat, but it attempts to escape as he switches on and is killed when only half of its body is transmatted to Hirath’s surface.
Sam is horrified when the wounded Tanhith sacrifices the last K’Arme to the Kusks as a distraction so they can escape; the Doctor would never do such a thing, and this, Sam now realizes, is why she loves him. She and Tanhith follow the Kusks back to the transmat, but the Kusks spot them and pursue them into a forest of time trees. Sam tries to use the trees to dispose of the Kusks while Tanhith reaches safety, but he is caught up in a timequake and killed by the upheaval as part of the planet regresses to an earlier geological era around him. Sam returns to the transmat platform alone, but finds too late that it is low on power; she is stuck halfway between the planet and the moonbase as an injured Kusk approaches...
The Doctor uses the moonbase computers to convince the probe that it exists millions of years in the past, when the moon was orbiting much closer to Hirath than it is now; the simulated gravity shift will tear the probe apart and end the temporal instability. Unfortuantely, Sam’s attempt to use the transmat drains too much power at the critical moment, and before the Doctor can do anything the Kusks return for their technician. The Doctor uses his own body as a live conduit to complete the circuit. The probe tears itself apart, the attacking Kusks are electrocuted and Sam arrives on the moonbase in one piece -- only to find that the Doctor has apparently been killed. Refusing to accept his death, she tries to revive him with mouth-to-mouth, ends up frantically kissing his body, and then flees hysterically into the moonbase corridors and knocks herself out on a fallen girder. As the life support systems begin to fail, Anstaar takes Sam to the Kusk ship to escape, but it seems to be taking her away from her home system; therefore, Anstaar departs in an escape pod, assuming that Sam has learned from the Doctor how to take care of herself. Back on the moonbase, the Doctor recovers to find that although he’s saved the day once again, there is no sign of Sam and he has no way to know where he should start looking for her...