Following the events of Invasion of the Dinosaurs, Captain Mike Yates was discharged from UNIT and is now attending a Tibetan meditation centre in rural England. He is visited by Sarah Jane Smith and they witness some curious happenings at the centre, seemingly organised by a resident called Lupton, a middle aged former salesman, and his cronies. Mike and Sarah stumble across Lupton performing an incantation, which conjures up a giant spider into the middle of the basement room. It jumps on Lupton’s back and then disappears. The spider manifests itself in Lupton’s head, telling him to seek out and locate a certain blue crystal.
The Third Doctor has developed an interest in psychic ability, but his testing of a clairvoyant called Professor Clegg backfires when his subject has a heart attack. It is triggered when Clegg comes into contact with a blue crystal from Metebelis Three (sent back from the Amazon by Jo Grant), which caused him to see the image of deadly spiders. Sarah returns from the retreat, having left Mike to watch things there, and she and the Doctor swap spider tales. Meanwhile Lupton has also arrived at UNIT HQ and steals the crystal from the Doctor’s laboratory. A multi-vehicle chase ensues which Lupton escapes by teleporting himself back to the monastery. Once there, the spider reveals that it is plotting against some of its sisters back on Metebelis Three. The spiders and the crystal originate from the same blue planet in the Acteon Galaxy, which was none too hospitable to the Doctor the last time he visited (during The Green Death).
The Doctor and Sarah now make for the monastery and tell the deputy abbot, Cho-Je, that something is very amiss. The crystal now strays again when it is taken by Tommy, the simple-minded handyman of the retreat, whose mind is opened and improved by the power of the crystal. Lupton is teleported to Metebelis Three, unconsciously allowing Sarah to follow him. She soon meets the human slave inhabitants of the planet, a generally dispirited bunch, other than the rebellious Arak, who flees to the mountains.
The planet is ruled by the Eight-Legs or giant spiders, and their Queen is the supreme ruler. They govern using guards chosen from among the planet's Two-Leg (human) population and their own phenomenal mental powers, amplified by the blue stones of the planet. The Doctor arrives on the planet and he makes contact with Arak, who explains that the Metebelians are the descendants of the crew of an earth space ship, which crashed hundreds of years before. A spider on board found its way to the Blue Mountains where, through the effect of the crystals, its progeny grew larger and larger and cleverer and cleverer. The Doctor works out that a “negative” stone can absorb and reject the power of the blue crystals and starts a revolt among the humans, but this is defeated and the Doctor ventures to the Blue Mountains. There he encounters the Great One, a giant spider which controls the world of Metebelis and desires power over other domains too. She knows the crystal is still on Earth and sends the Doctor there to get it for her. He flees back to Earth with Sarah – not knowing the Queen spider has now implanted itself in his companion's mind.
Tommy has given the crystal to the abbot, K’anpo Rinpoche, who is an elderly Time Lord and the one-time hermit mentor of the Doctor. He now lives in peaceful exile on Earth. He tells the Doctor of Sarah's control and they work together to expel the Queen Spider. A fight breaks in the monastery between Lupton’s cronies and the Abbot’s men. The Abbot advises the Doctor to take the crystal to the Great One: the Doctor started this chain of events by removing the crystal in the first place, and it is up to him to put it back. He departs in the TARDIS with the crystal.
On Metebelis Three, Lupton has been killed by the spiders after falling out with the Spider Queen. When the TARDIS lands, the Doctor heads to the cave of the Great One and gives her the crystal, which she uses to complete a lattice that begins to magnify her mental powers. However, the forces unleashed are too strong for the Great One and the positive feedback kills her and the other spiders. A vast wave of deadly radiation floods the cave. The Doctor, now very weak, staggers back to the TARDIS and teleports away.
Three weeks later, Brigadier Lethbridge-Stewart and Sarah are in the Doctor's laboratory when the Doctor returns and promptly collapses. The abbot K’anpo arrives in his new body, having regenerated into the form of Cho-Je, who was a sort of forward projection of his soul. He tells them that the Doctor will change too and before their eyes the Doctor starts to regenerate into the Fourth Doctor.