On the planet Iwa, a human medical facility called the Refuge is under attack by alien “foxes” with the ability to disintegrate and reconstitute their bodies, apparently at will. Most of the security guards have been killed, and the medical staff have been recruited to defend the base. Co-ordinator William Mosely is entirely out of his depth, and morale is plummeting -- especially when Mosely receives a reply to his distress call informing him that the nearest ship is five months away. In order to survive until rescue comes, the staff are advised to barricade themselves within the Refuge and retreat into metabolic suspension in the “dream chambers” in which the patients are treated. However, there aren’t enough chambers to support all of the staff as well as the patients.
While defending against another fox attack, the idealistic young Juniper encounters a stranger outside the Refuge, an old man who takes little interest in the battle and demands that he be allowed to search for his missing companion. The humans force the old man to accompany them into the Refuge, where he is decontaminated and his clothing burnt to ensure that no scraps of the foxes get inside the Refuge. In exchange, he is given the uniform of a doctor. Mosely, grasping at straws, concludes that the doctor (who refuses to give his name) must have been sent from Earth to provide them with help, unofficially. The Doctor claims that this is the case, but that only his companion can pilot the rescue ship. Mosely thus sends out a squad to search for the missing girl, led by a bitter ex-military officer named Cass.
While the search is on, Mosely asks the Doctor to help the Refuge’s only surviving engineer, Webber, investigate recent power surges which threaten the stability of the dream chambers. Though uninterested in doing so, the Doctor needs something to occupy himself, and thus listens as Webber explains that the Refuge is an experimental corporate facility for the treatment of Future Deviants, children born with genetic traits which it’s believed will result in their developing criminal tendencies. The Doctor examines the base’s power supply, determines that the fault originates within the dream chambers, and theorises that the power surges are being caused by an active telepathic mind within the dream matrix. The Doctor enters a dream chamber himself in order to test his theory, but finds himself trapped in a shared illusion with two adult humans whose mouths are fraying away from their bodies. He is then transported outside the building containing the two humans, and sees a baby crawling towards the building while monsters lurk in the long grass.
As yet, the old man is unaware that his companion is also inside the dream, having fled from the foxes through a broken panel on the exterior of the Refuge only to find herself somehow in here. Unaware that her surroundings are an illusion, the girl makes her way to the strange building, where a cat leads her to a young girl named Jill who is hiding in a cupboard. Jill’s mouth has also frayed off, but she can still speak telepathically, and she names her new friend Susan, after her mother. Jill claims to have heard Susan’s telepathic screams and rescued her from the monsters so that Susan can help find Olmec, Jill’s best friend. Olmec used to tell Jill stories, including the myth of the death god Hunhau -- and elsewhere in Jill’s dream, Mentors Parm and Baine, whom Jill hates, are about to meet Hunhau for themselves...
Outside, Cass orders a squad including Juniper to search for the missing “pilot” in the ruins of a crashed spaceship, though fully aware that there will be nowhere for them to hide if the foxes attack. This is exactly what happens, and in the ensuing havoc, Juniper is shot and injured by one of her own people. Juniper calls the Refuge for help, but when Mosely receives the call he disconnects immediately, convinced that Juniper is doomed, unwilling to listen to her death and blaming himself for his failure to save her.
Webber pulls the Doctor out of the dream chambers when another power surge threatens his life, and the Doctor emerges convinced that one of the patients is a powerful telepath who has taken control of the dream matrix. Webber pulls up a list of patients, and the Doctor recognises the two people he saw in the dream -- Parm and Baine, who were injured during a fox attack and placed in the dream chambers for treatment. Both have just died, during the power surge, and when Webber admits that they were unpopular amongst the children, the Doctor theorises that the telepath is a child who drew Parm and Baine into her dream for revenge.
The Doctor also recognises another face, which he saw carved into a door in the dream building. Webber identifies this as Olmec, keeper of the petting zoo and a popular Mentor. When the fox attacks began, Olmec tried to rescue the animals and was mortally injured; he too was placed in a dream chamber, but will probably never awaken from his coma. Although the children were never told the details of the incident, Webber now recalls hearing Mentor Parm shouting at a child later about “making up foolish stories”, and theorises that this could be the telepath. However, as Webber checks the records to find out who was in the ward on that particular night, the Doctor discovers that one of the dream chambers contains a patient with no records and non-human vital signs, and realises to his horror that his companion is also trapped in the dream.
Juniper and Mette survive the fox attack and report to Cass, who reports to Mosely. Relieved to hear that Juniper is not dead, Mosely orders them all to return to the Refuge immediately. Instead, Cass informs the other soldiers that Mosely has ordered them to continue the search, and has Juniper injected with an anaesthetic before she can protest. Cass then shoots Mette in the head and has the squadron’s bodies taken back to the Refuge, claiming that Juniper panicked when the foxes attacked and shot Mette herself while trying to escape. Angered by Mosely’s incompetent leadership, Cass intends to let the other soldiers believe that Mosely is keeping them out on a wild goose chase, stage a coup and take control of the Refuge herself; and now, nobody will believe Juniper if she says otherwise. However, Cass hadn’t put the bodies through decontamination before taking them into the Refuge, and as Juniper struggles to shake off the effects of the anaesthetic, she sees a fox assemble itself from scraps within one of the human bodies and walk into the Refuge...
The Doctor and Webber report to Mosely that the power surges are being caused by Jill Helright, a telepath so powerful she was able to hide the full extent of her abilities during the medical tests. She has been drawing power from the rest of the Refuge in order to create her own dream within the chambers, but if she is simply removed, everyone within her dream -- including the Doctor’s companion -- will be killed. Mosely nevertheless orders Webber to do so, but as he and the Doctor protest, the fox inside the Refuge bursts into Mosely’s office, triggering an automatic alarm. It does not attack, however; rather, it prostrates itself before Mosely and telepathically communicates that its people intend to destroy the dream chambers. The Doctor, who had suspected that the foxes’ ability to disintegrate and reintegrate their bodies did not evolve naturally, now begins to believe that they actually came here seeking help.
Before the Doctor can communicate with the fox, Cass arrives in response to the alarm and opens fire on the fox -- and when the fox disintegrates, one of Cass’s shots hits Mosely, perhaps by accident. As she wished, she is now in charge of the Refuge and free to organise its defence as she sees fit. Webber and the Doctor try to convince her that it may be possible to make peace with the foxes, but she refuses to listen, and attempts to place them under arrest for treason. The Doctor flees to the dream chambers to rescue his companion, followed by Webber, and Cass orders the perimeter guard Salih to find and arrest them both. She then finds that Mosely is still alive, and tries to smother him with his own pillow -- but is interrupted by a crisis. The perimeter guards have all entered the Refuge in response to the alarm from within, and the foxes have taken advantage of their absence to attack and enter the facility.
Inside the dream, Susan finds her own mouth fraying away, Jill’s dream interpretation of the Mentors’ attempt to remove her telepathic ability. Olmec’s injuries are too grave for him to enter Jill’s dream, and the young girl has thus come up with a plan to lure him here. This building’s floor is made of cheese, which attracts rats and mice, which attract cats, which Jill believes will attract Olmec. The plan appears to work, but Susan realises from Olmec’s childlike behaviour that this is not the real man but Jill’s idealised dream version of him. Furious, Jill summons Hunhau, the death god, convinced that the real Olmec will sense that she is in danger and arrive in time to save her.
Webber finds the Doctor preparing to enter a dream chamber, and helps him to do so; although he has by now realised that the Doctor is not human, and that he’s motivated only by the safety of himself and his friend, he knows that the Doctor’s actions will nevertheless help everyone in the Refuge. Somewhat abashed, the Doctor explains that he intends to draw power away from the dreamscape and isolate it from the rest of the system. The Doctor thus enters Jill’s dream once more, but becomes overwhelmed by the illusion and is unable to complete his work. Outside the dream, however, Webber realises what has happened and completes the connections himself.
Realising that Cass is indeed out of control, Salih gives Juniper an adrenalin shot to wake her up. Cass is trying to bully the guards into following her orders, unable to comprehend that she is the only one with a real military background and that she’s expecting far too much from security staff trained only to stop children from throwing tantrums. Salih arrives and shoots Cass, and as the foxes approach, Juniper rolls a medical trolley packed with explosives into the corridor, burying Cass under the rubble and creating a barricade to keep the foxes out of the dream chambers. However, the fox which smuggled itself in and confronted Mosely reappears, having drawn on Mosely’s body to reconstitute itself. Through him, the fox is finally able to communicate with the humans, and it explains that its people came here for help, drawn by the minds within the chambers. Unable to make the others within the Refuge hear their telepathic communication, they attacked the guards and the dream chambers out of desperation, reasoning that with no one to defend them and nowhere to retreat to, the medics would have no choice but to assist them. The battle only lasted this long because the medics were conscripted to defend the Refuge, and the foxes, seeing their uniforms, assumed that they too were soldiers. Juniper and Salih surrender on behalf of the survivors, and the foxes cease their attack.
The Doctor finds his way back to Jill’s dream building, where Susan and Jill are being attacked by Hunhau. At the last moment, Olmec arrives and banishes Hunhau, telling the death god that he is merely a story with no real power. The dream begins to fall apart as Webber finishes his work, and as it does so, the baby from outside the building arrives and begins to transform into a fox. Olmec takes Jill deeper within the dream to a place of safety, while the Doctor and Susan escape to the real world. When the Doctor awakens, he is surprised to find that Webber understood and finished his work -- and he is joyously reunited with his granddaughter.
In the aftermath, the foxes explain that they had sent one of their own kind into the dream chambers to sabotage them; this was the real reason for the power failures, and in fact, Jill’s dream was the only thing keeping the system stable. Jill is now an integral part of the dream matrix, and she may never awaken. However, the foxes agree to leave the dream chambers alone, on condition that the humans do not try to use them to escape; and inside the dream, Jill and Olmec are together again. Since the humans have no option, they agree to help the foxes find a cure for their genetic instability. The old man and his granddaughter leave the humans and foxes to their uneasy peace, and as they go, the girl admits that she’s decided to keep the name Susan. The old man admits that he also enjoyed having an official title, and decides that this species, humanity, merits further study -- and that it may even be possible for him and Susan to hide out amongst them for a time.