An alien spaceship lands on the colony world of Espero, and a young boy named Joshua accompanies his father and uncle Ake to investigate. The people of Espero do not take kindly to aliens, and when the ship’s horse-like occupant emerges, the older men gun it down without waiting to see if it’s trying to communicate with them. The men burn the alien body and its ship and return home, but Joshua’s father takes a medallion from the body as a keepsake. Later, deeply disturbed by what he’s seen, Joshua sneaks into his father’s room for a closer look at the medallion...
In the city of Saiarossa, a teenager named Calamee and her pet -- a small, green monkey-like “mokey” named Nessus -- literally run into a white-skinned stranger who is fleeing from Imperial guards. Calamee impulsively helps the stranger to escape, and he later admits that he’s forgotten who he is and how he came to be here. He knows his name is the Doctor, but apart from that, all he remembers is waking up in the fields and wandering into the city. The frightened and hostile locals directed him to the Palace, but something about the guards’ too-friendly behaviour gave him the impression that it would be better if he left quickly. Intrigued, Calamee decides to take the Doctor to an old family friend, Father Roberto of the Church of Forgotten Saints, for sanctuary.
Trix has been waiting in the TARDIS for hours while the Doctor and Fitz investigate a distress signal, and when she eventually gives up waiting and emerges, she finds Fitz lying unconscious in the field outside. When he awakens, he has trouble remembering what happened, and indeed who Trix is. He soon recovers most of his memories, and, somewhat uncharacteristically, seems eager to set off and investigate the mystery. He and Trix find no sign of the Doctor outside the ship, but they do find a patch of vegetation which is dissolving into a greyish goo -- and are driven from the area by a fierce animal snarling, possibly the sound of whatever attacked the Doctor and Fitz.
Meanwhile, at the Palace in Saiarossa, the Imperial family is going about their daily routine of treachery. The 120-year-old Imperator, Tannalis, is fully aware that his wife, Alinti, and son, Javill, are plotting to kill him, and that his daughter, Sensimi, has laid plans of her own to stop them, with the unwilling help of her maidservant Farine. However, Tannalis has made a deal with an offworlder named Trove, and intends to give Alinti a surprise at his birthday celebrations tomorrow. Trove is laying other plans in case his deal with Tannalis falls through, however, and when he sees that Javill is greedy for offworld technology, Trove offers him a holographic colour generator -- a mere toy, but enough to entice Javill with the thought that Trove could supply him with more such technology. Trove is also intrigued by the Doctor, who may be searching for the same thing as Trove -- which is why Trove has arranged for him to be monitored...
Father Roberto is initially reluctant to open his doors for the Doctor, but the Doctor’s evident interest in the faith and the history of the planet soon wins him over. Roberto explains that Espero was founded by members of the Ecumenical Council who purchased Espero from the Homeworld Corporation. Their intention was to make a fresh start on a new world, putting the past behind them and spreading their faith to the outer planets. However, Homeworld failed to inform them that Espero’s mineral resources were inaccessible without advanced technology which the colonists couldn’t afford; the other colonies in this sector are occupied with their own problems; and the alien civilisations have their own religions and aren’t interested in Espero’s. The colony has withered, and most of its inhabitants feel that other worlds have turned their backs on Espero. In addition, many of the dark-skinned Esperons remain bitter about their harsh treatment at the hands of the whites on Earth, which is why the Doctor has met with such hostility.
Roberto advises the Doctor to find out what it is he’s forgotten, and suggests that he seek help from another mysterious offworlder, Madame Xing. While Roberto tries to contact Madame Xing, the Doctor goes to a nearby restaurant, and Calamee accompanies him; this is the most exciting thing that’s ever happened to her, and she wants to see it through. A stranger then greets them, and somehow transports their table out of the restaurant and into a small parlour, where Madame Xing is waiting, her face hidden beneath a veil. She analyses the Doctor’s mind and determines that his memories have been tampered with several times -- and that on the most recent occasion, the memories were deleted rather than simply being suppressed.
At the Doctor’s request, Madame Xing restores what memories she can, and the Doctor swears out loud when he remembers Fitz, Trix, the TARDIS -- and the death of his daughter Miranda. The Doctor orders Madame Xing not to restore any more of his memories, but she supplies him with a viroid unit which will restore all of his lost memories, should the Doctor choose to use it. The Doctor and Calamee then find themselves back in the restaurant. Calamee demands to know why the Doctor doesn’t want to remember his past, and, irritated by her persistent questioning, the Doctor swats a large fly out of the air as it buzzes around him -- only to find that it is in fact a miniature robot camera, something far beyond Espero’s level of technology. His escape from the Palace was arranged by an offworlder who’s been keeping tabs on him ever since. Also, for some reason, the Doctor is dying for a cigarette.
Fitz and Trix escape from whatever was snarling at them, but Fitz refuses to return to the safety of the TARDIS without the Doctor. Instead, he makes his way towards the distant city lights, and Trix reluctantly accompanies him. In the side streets of Saiarossa, they see a showman named Deel preparing to unveil a caged “night beast” to a curious crowd. The beasts have been showing up outside the city for about a year now, and nobody knows where they’re coming from. The creature is making the same snuffling sounds as the thing that attacked Trix and Fitz, but Fitz’s curiosity goes unsatisfied, as a bystander overhears Trix mentioning the Doctor and directs her towards the restaurant where he and Calamee were dining. However, the Doctor and Calamee have gone by the time Fitz and Trix arrive at the restaurant.
The crowd eventually drifts away from the cage, and the unattended night beast picks the lock and escapes. Soon it is surrounded by a terrified mob. Fitz and Trix investigate the commotion, and Fitz tries to place himself between the mob and the creature, which seems to be intelligent and capable of communicating. However, its apparent placidity gives the mob courage to attack, and as white-skinned offworlders, Fitz and Trix come in for a share of the violence as well. As the mob descends upon the night beast and beats it to death, a woman who identifies herself as Farine leads Fitz and Trix to safety, and demands that Fitz, who seemed to have some affinity with the night beast, tell her where they’re from and whether they can be trained.
While Fitz speaks with the arrogant Farine, Trix notices a small boy watching them from an alley. The boy, who identifies himself as Reo, asks Trix about the “soldier” which Fitz was speaking to, and claims to be looking for a lost toy which could be the most valuable thing on the planet. Trix, intrigued, fails to notice until it’s too late that Fitz and Farine have left without her, and she and Reo are then set upon by three thugs who prepare to beat Trix to death just for being an alien. Before they can do so, Reo’s body doubles in size, and the thugs beat a hasty retreat. Reo offers to give Trix the device that enables him to do this, and Trix, always on the lookout for a good disguise, tries to be clever and agrees to help Reo only if he lets her test the device first. However, when Reo hands over the device and Trix attaches it to her skin, her body is taken over by an alien intelligence. The boy collapses, and the alien, Reo, informs Trix that his real name was Joshua; however, Joshua’s personality was subsumed by Reo’s when he picked up the alien medallion in his father’s room. Reo finds Trix’s body more suitable for its purposes, and it thus suppresses Trix’s memories of this encounter while it waits for the medallion to gain total control of her body. Trix thus sets off for the palace in search of Fitz, having forgotten everything that’s just happened to her, and unaware that Joshua has just died in the alley, as his body no longer remembers how to function without Reo controlling it.
Meanwhile, outside the city, the guilt-stricken Ake returns to the wreckage of the alien ship, only to step into a patch of grey goo that used to be vegetation. Even as he realises that the line of goo stretches out to both sides as far as he can see, his body dissolves into the goo. It is then reconstituted, but Ake is no longer quite the same man he was, and he remains seated on the ground, terrified, as the wavefront slowly moves towards the city.
The Doctor overhears a man talking about the incident with the night beast and investigates; the night beast’s body has been removed, but the Doctor takes a blood sample to analyse in the TARDIS. On the way, Calamee’s questioning wears him down, and he explains that he’s tried several times in the past to recover his lost memories, and has always failed; but he’s learned enough to know that he might not like those memories if they ever returned. He’s come to terms with his amnesia, is perfectly happy with who he is now, and sees no reason to change that. Calamee accepts this explanation, and as the Doctor takes her and Nessus back to the TARDIS, he realises that he’s uncharacteristically attracted to her.
When Fitz realises that Trix is missing, he demands that Farine return for her, but “Farine” drops her charade and admits that she’s really Princess Sensimi; she used her maid’s identity to get out of the palace unnoticed so she could see the captive night beast. She reluctantly flags down two passers-by, and gives them her identity card and instructions to find Trix and direct her to the palace. Fitz then accompanies her to the palace, where she tries unsubtly to find out what he knows about the night beasts. Before he can admit that it’s not very much, her father summons her for a chat, so he can advise her not to worry about Alinti and Javill’s plots. Alone in Sensimi’s quarters, Fitz falls asleep and has a disturbing dream about himself and the Doctor, their two naked bodies merging into one. As he sleeps, Sensimi’s pet mokey, Looloo, spots a flycam buzzing about the room, snatches it out of the air and chews it up. Trove is irritated; he still doesn’t know if the newcomers are working for his own employers, the Oon, or their enemies, the Makers, and in any case it’s vital that he find his target before they do.
On their way to the TARDIS, the Doctor and Calamee encounter the strange wavefront, which reaches up to a metre above the ground. Disturbed, the Doctor urges Calamee to run to a nearby barn and climb up into the loft, but he slips while climbing the ladder and falls into the wavefront as it passes. It has no effect on him physically, but transforms all other organic material it touches into grey goo. The Doctor takes a sample of the goo to analyse back in the TARDIS, and on the way, he and Calamee notice that the grass and weeds are reconstituting themselves from the goo.
In the TARDIS, the Doctor completes his analysis and determines that, whatever the wavefront is, it’s going to consume the entire planet if left unchecked. At Calamee’s urging, the Doctor pilots the TARDIS to the palace to warn the authorities of the danger, and it materialises in the cellars just as Fitz and Sensimi arrive to examine a night beast which Sensimi has penned up in a cage. Fitz and the Doctor are thus reunited, and Calamee is startled when Nessus nestles in the night beast’s fur, apparently feeling some affinity with the creature. While trying to coax him back into her arms, Calamee notices scraps of Alinti and Javill’s clothing in the cage, and Sensimi is forced to admit that she’s been trying to train the night beast to associate the scents with food so it will attack her mother and brother.
The Doctor decides to release the night beast, believing that it will lead him to the source of the distress call he picked up. Before he can do so, Trove arrives with the palace guard and tries to arrest him, but Sensimi intervenes. The Doctor then tells Trove about the wavefront, and Trove, understanding its significance, realises that he’s running out of time. Trove thus returns to his quarters, intending to release the night beast and use his flycams to follow it -- but his flycams are gone, and the surveillance footage from Trove’s security monitors reveals that Javill is responsible. Trove confronts Javill, who admits that he searched Trove’s quarters, hoping to find more interesting offworld technology; unfortunately, he has a fear of insects, and when the flycams he’d found started to move in his hand, he instinctively dropped the case and smashed them all. Furious, Trove shows Javill another of his “toys”.
The Doctor tells Sensimi and Fitz about the wavefront, which seems to break down, streamline and reconstitute DNA strands. Whatever has created it may also have created the night beasts, which the Doctor believes are genetically re-engineered mokeys; this would explain why Nessus felt so comfortable with the creature in the cellar. Sensimi leaves to warn her father, but first runs into Alinti, who promises to send out a warning to the city about the wavefront. After confirming that some kind of disturbance is indeed approaching Saiarossa, Alinti sends out the warning -- and makes sure that nobody informs Tannalis.
The Doctor, Fitz, Sensimi, Calamee and Nessus set off to find the source of the wave. Trove has sealed off the TARDIS, and they thus leave the palace in one of the levicars which Tannalis has ordered in for his birthday celebrations. Unfortunately, as they approach the wavefront they see that it’s drawing energy from the conversion process to sustain itself, which means that it’s expanding as it moves forward. By the time it reaches the city, it will be higher than the upper floors of the buildings in which the population is hiding, and there’s no time to return to the city and warn them. Fitz is shocked when the Doctor curses about this -- which confirms some of the Doctor’s suspicions about his recent behaviour. In order to get over the wavefront safely, the Doctor drives the levicar up and over a tree, but the levicar crashes on the other side of the wavefront and he and his friends must proceed on foot.
Trove has programmed his last remaining flycam to follow the Doctor, and he now contacts the Oon to report his progress. The Oon are engaged in a holy war against the Makers, and they do not take failure well; nevertheless, Trove promises to deliver what they want within 20 hours. As he signs off, he realises that Alinti has been listening to him and now knows that his deal with Tannalis is more complex than she’d imagined. Aware that Tannalis might die before Trove gets what he’s looking for, he offers to make a deal with Alinti instead, and when he tells her what he’d offered Tannalis, she agrees to help him stop the Doctor.
The two women whom Sensimi stopped in the street earlier find Trix and directed her to the palace, and before Javill’s unfortunate encounter with Trove, Trix overhears a conversation between him and Alinti which implies that they’re plotting to poison Tannalis at his birthday celebrations. Looking for Fitz, Trix instead stumbles into Tannalis’ room, but his spies have already told him of her presence and he invites her to sit and chat for a while. He soon determines that she does not have any connection with Trove -- at least, none that she knows of -- and thus explains to her that, in exchange for certain services, he has put his palace at Trove’s disposal while Trove searches for a device of some sort. Farine then arrives to inform Tannalis that Trove and Alinti have left the palace, and Tannalis takes the opportunity to break into Trove’s quarters and find out what he’s really looking for. Trix finds the controls for Trove’s flycams -- and Tannalis finds the catatonic Javill locked in Trove’s cupboard.
The Doctor and his friends return to the area where the TARDIS materialised, and there, they meet a night beast which directs them to a small forest grove. This is where the Doctor and Fitz were attacked, and Calamee claims to have been here about a year ago on a picnic, just before the night beasts began to appear. The Doctor theorises that something took Nessus and used his DNA to create the night beasts -- and when he and his friends take a close look at the vegetation, they see that it is being devoured by maggots and is devouring the maggots in turn. The night beast then unexpectedly flings the Doctor and Fitz against a tree, which absorbs them into itself -- and transports them to an organic spaceship named Tain, which is buried beneath the grove and has now become a part of it. Tain restores some of the Doctor’s and Fitz’s lost memories, and they recall being attacked by a night beast after they emerged from the TARDIS. Tain rescued them and tried to repair the damage to their bodies, but he is currently engaged in a struggle with a Trojan program in his systems, and the Trojan interfered with the repair, leaving the Doctor’s and Fitz’s memories incomplete and causing them to exchange certain personality traits.
Tain explains that he was constructed by a race called the Makers, who are at war with another race called the Oon. After centuries of warfare, he has come to realise that he is responsible for the deaths of countless innocents, and has fled, trying to put the war behind him. Before he escaped, however, the Oon infected him with a Trojan which has been trying to take over his body. Tain crashed on Espero and disabled his communications unit, and ever since, his personality has been struggling with the Trojan for control. The Trojan has been creating genetically engineered soldiers -- the night beasts -- to draw attention to itself, but Tain has interfered in their development, making them more docile and intelligent. However, the Trojan recently regenerated the ship’s communications unit and sent out a distress signal -- and when the TARDIS materialised in response, Tain panicked and triggered its ultimate weapon, the Gaian wavefront.
The wavefront is transforming everything it touches into a single organic gestalt with the bioship at its centre. The Doctor was spared because he had already been touched by Tain, but every other organism on the planet is becoming part of the gestalt, which is eternally consuming itself to reflect the struggle for control between Tain and the Trojan. When the process is complete, the Makers and the Oon will be unable to separate the bioship from the planet, and will have to leave it where it is -- or sterilise the entire world. The Doctor is enraged, particularly when Tain admits that the wave will soon become self-sustaining and hence unstoppable. How can the Doctor trust Tain to do the right thing when he has unleashed this upon the people of Espero? Before Tain can answer, the Trojan gains the upper hand and a night beast begins to push itself out of the wall; however, Tain manages to hold it back while the Doctor and Fitz escape.
Alinti and her bodyguard accompany Trove to the grove, following the flycam; Trove boosts his levicar’s repulsor field to get them safely through the wavefront. As the levicar descends upon the grove, two night beasts emerge from the tree, and the guards open fire on them. Trove, unable to lift the levicar to a safe height, kicks Alinti out while the guards are looking the other way. The night beasts tear Alinti to pieces before Sensimi and Calamee’s eyes, but the levicar rises to a safe distance and the guards are able to pick off the night beasts. Trove then pulls out the device he used on Javill and holds it to Sensimi’s head, threatening to kill her unless the guards force Calamee to tell him where the bioship is. However, Trix and Tannalis then arrive, having used the flycam system that Trix found in Trove’s rooms to track him down. Tannalis, enraged by what Trove has done to his son, calls off their bargain, and Trove realises that Sensimi is now useless as a hostage; if he kills her, the guards will strike him down immediately.
At this point, Reo seizes full control of Trix’s body. She is unable to resist, and knows that soon she will be dead -- and the worst part is that she chose of her own free will to take the Maker’s medallion from Joshua. As the Doctor, Fitz and the new night beast emerge from the tree, Nessus attacks Trove, who kills him with one blow -- but Reo then attacks Trove, moving with superhuman speed and kicking him back into the arms of the night beast, which snaps his neck. The night beast does not attack the Doctor or Fitz; presumably, it can scent Tain’s smell on their clothing, which is presumably also why the one in the city didn’t attack Fitz. The guards shoot the night beast before it can harm anyone else, but Trix/Reo then enters the tree, and, after a moment’s thought, the Doctor seizes Trove’s weapon and follows her in, leaving Fitz to comfort Calamee as she mourns for her dead pet.
Tain is losing the struggle against the Trojan when Reo enters, offering to cure his “illness” and take him back where he belongs. The Doctor tries to convince Reo to honour Tain’s decision to put the war behind him, but to no avail. Before he can intervene, Reo removes the device from Trix’s chest and attaches it to the wall, and as Reo’s consciousness passes from Trix into Tain, Trix collapses; as with Joshua, her body has forgotten how to function on its own. Tain manages to link himself to Trix’s body in order to keep her alive, but this leaves the Doctor with a dilemma. Trove’s weapon is a neural eraser, and he’d intended to use it against Tain, erasing both Tain’s personality and the Trojan from the bioship’s body. If the Doctor uses it on Tain now, it will erase Tain, the Trojan, and Reo, and stop the Gaian wave -- but while Tain is willing to submit to this, he’s now all that’s keeping Trix alive, and using the mind-scrubber will kill her as well. The Doctor has only one other choice. He’s found the Makers somewhat familiar, and perhaps if he uses the viroid supplied by Madame Xing to restore all of his lost memories, he will remember something that will enable him to defeat Reo and save both Tain and Trix.
Fitz finds the flycam controls and sends Trove’s flycam into the bioship to find out what’s going on. There, he finds the Doctor struggling to make his decision, but when the desperate Doctor asks Fitz for advice, Fitz finds one of his own lost memories returning, and comes up with a plan. Once before, Tain took Nessus apart and then reconstituted him; if Reo allows Tain to do so again, for Calamee’s sake, Fitz promises that the Doctor will stop interfering. Reo agrees to his terms, and though the Doctor suspects that Fitz has passed on a hidden message to Tain, he also agrees. Tain thus reconstitutes Nessus’ body -- but before the Doctor can react, Nessus grabs the mind-scrubber and fires it into the wall, erasing both Tain’s and Reo’s minds and causing the Gaian wave to collapse just as it’s about to reach the city.
Nessus then connects himself and Trix back to the walls -- and, speaking in Tain’s voice, reveals that Tain transferred his personality into Nessus’ body, thus surviving when he fired the mind-scrubber into the bioship. Tain now transfers his personality back into the bioship’s body and resumes the task of keeping Trix’s body alive. However, since the mokey’s brain was much smaller than his own, he was forced to discard most of his memories -- and, though he is still aware of the horrors he perpetrated in his past, he can no longer recall the terrible details. Once Trix has fully recovered, she and the Doctor return to the surface, along with Nessus, who is now, once again, simply a mokey.
Tannalis admits that Trove had promised to rejuvenate his elderly body, and Tain honours the deal, giving Tannalis a new lease on life. Now, though he won’t get the pleasure of seeing Alinti or Javill’s face when he does so, Tannalis can and dissolve the Imperatorship and make Saiarossa a true democracy, just as he’d intended. Tain also finishes its work on the Doctor and Fitz -- but Fitz, who has regained most of his own lost memories (including his recreation in the remembrance tanks of Anathema, which is what gave him the idea for the plan with Nessus), asks Tain not to restore all of the Doctor’s lost memories. The Doctor is thus in the same position as Tain: aware that there are horrors in his past, but not haunted by the details. Madame Xing has been watching from hiding, and, disappointed, she departs from the planet with her companion, hoping that one day she will get another chance to restore the Doctor’s memories.
Tain restores the few people caught up in the Gaian wave to their former selves, and prepares to leave the planet so as not to draw the Makers or the Oon back to the people of Espero. Calamee, eager for adventure, convinces him to take her and Nessus with him. Tannalis and Sensimi will no longer be an Imperial family, and they will do their best to care for Javill, who now has the mind of a child. The Doctor and his companions also prepare to depart, but first, Trix visits Joshua’s home and drops off some of the treasures she’d stolen from the Imperial palace; however, she vows not to let these bad memories haunt her.