Following his regeneration, the Doctor and his companions return to the TARDIS avoiding the radio telescope’s security guards. Just before they can depart, Adric is seemingly attacked by the Master's TARDIS, currently disguised as a Corinthian column. Adric is brought into the TARDIS which then dematerialises. The Doctor acts oddly due to the after effects of his regeneration and asks to be taken to the "Zero Room" — Time Lord healing technology. In his delirium, the Doctor makes various comments about previous companions such as the recently-departed Romana.
Without the Doctor to pilot the ship, Tegan investigates the TARDIS's controls and finds a computer system which gives her instructions on how to fly it. She notices that their preset destination is listed as hydrogen inrush — Event One.
Having found a new costume — a cricketer's outfit — the Doctor enters the Zero Room. After giving instructions to Nyssa and Tegan, they see an image of Adric who has been trapped in a web structure by the Master. As the TARDIS travellers find themselves being drawn into the event marking the creation of the galaxy, the Master appears to them on the TARDIS scanner to gloat at their imminent demise. The Doctor emerges from the Zero Room and jettisons 25% of the TARDIS’s rooms to save them from destruction; however, one of the ejected rooms was said Zero Room. Meanwhile, the Master reveals to the trapped Adric that he has a further trap set for the Doctor. Tegan searches the TARDIS computer systems and finds a place named the Dwellings of Simplicity on Castrovalva which will be a suitable place for the Doctor to recover from his regeneration.
The companions make a cabinet from the remains of the Zero Room. Upon arriving at Castrovalva, they carry the coffin-like cabinet containing the Doctor out of the TARDIS and start to search for the Dwellings. Soon they spy a figure wearing brightly coloured armour, so they hide the box. On returning to the box however, they find the Doctor has vanished…
Nyssa and Tegan follow a trail of blood and find a citadel. They see the Doctor ahead, but he is surrounded by warriors who take him into the city, leaving the girls to ascend the high rocky walls.
In the fictional city, the Doctor is questioned by Shardovan the librarian. Unable to answer their questions, he is given a room where he is then visited by the elderly Portreeve. Nyssa and Tegan arrive in the city and meet Shardovan. During the night, Adric is seen lurking in the Doctor’s room. The next day, an image of Adric appears in a mirror to Nyssa, who warns her about the Master being in Castrovalva. He is actually still trapped in the Master's TARDIS.
The Doctor wakes up and is shown a magnificent tapestry by the Portreeve. The tapestry depicts scenes as they happen in the outside world. The Doctor soon realises that Adric is missing and sets out off to find him, but as they search the city of Castrovalva they keep finding themselves in the same courtyard.
Nyssa says it is as if space was folded in on itself, and the Doctor agrees. The Doctor looks out of the window he says that they are caught in a recursive occlusion. Someone is manipulating Castrovalva — they are caught in a space-time trap.
The Doctor questions two of Castovalva's inhabitants, Mergrave and Ruther, whether they are able to see the folding. When asked to show the position of his shop on a map, Mergrave indicates its position in four different places. Ruther does the same when asked to show where the Portreeve’s house is. But, because they are part of Castrovalva, they cannot see that there is something wrong. The Doctor also realises that the history books of Castrovalva are all fakes — they appear to be 500 years old but chronicle events up to the present day.
The Doctor creates a ruse by filling the Zero Room cabinet with the history books and has the cabinet taken to the Portreeve. The Portreeve reveals himself to be the Master after the Doctor breaks into his house. The Master created the town of Castrovalva and placed its presence in the TARDIS computers as a trap. Ruther and Mergrave confront the Master and the tapestry reveals its true power: Adric trapped in the web. The power to create comes from block-transfer computations using Adric's mathematical genius.
Realizing the true nature of Castrovalva's reality, Shardovan swings from a chandelier into the web and destroys it. Seeing all is lost, The Master flees to his TARDIS which was disguised as a fireplace. The Doctor and his companions flee from the city. The Master appears to be trapped and is unable to escape as the city collapses in on itself. As the time travellers return to the TARDIS, the Doctor indicates that he has fully recovered from his regeneration ordeal.
Doctor Peter Davison (Fifth Doctor)
Companions Matthew Waterhouse (Adric)
Sarah Sutton (Nyssa)
Janet Fielding (Tegan Jovanka)
Anthony Ainley – The Master/The Portreeve
Dallas Cavell – Head of Security
Frank Wylie – Ruther
Michael Sheard – Mergrave
Derek Waring – Shardovan
Souska John – Child
Writer Christopher H. Bidmead
Director Fiona Cumming
Script editor Eric Saward
Producer John Nathan-Turner
Production code 5Z
Series Season 19
Length 4 episodes, 25 minutes each
Originally broadcast January 4–January 12, 1982