Mankind is colonizing space at a fantastic rate. Some human space travelers are cruising near the outer planets of the solar system with their ship on autopilot. The ship's computer, and soon the human crew, is possessed by a strange virus. Reaching their destination, Titan Base, they proceed to take over the base as a breeding ground. The station manager, Lowe is able to send out a distress call.
The TARDIS is traveling through the same region, and is infected by the virus. The infection passes to the Doctor, but he is unaffected for the moment. He and Leela hear the distress call and go to investigate. While there, the Doctor is overcome by repeated infections and is chosen, due to his incredible powers as a Time Lord, to be the host of the Nucleus of the Swarm. Leela is unable to be infected.
The Nucleus declares her a reject and orders that she be killed. The Doctor manages to break free of his infection and tells Leela how to get the TARDIS to the nearest medical center. Accompanying them is Lowe, who has been infected, although the Doctor and Leela don't know this.
At the medical station, the Doctor's doctor, Professor Marius, introduces the group to K-9, a robotic dog he made to replace the real dog he had to leave on Earth. Professor Marius is baffled as to how to treat the Doctor's strange infection. Meanwhile, Lowe has been infecting the staff of the hospital.
Leela and the Doctor decide on a last-ditch strategy. They create clones of themselves, which can only survive for ten minutes due to problems with the technique. The clones will then be shrunk and inserted into the Doctor. There they will destroy the Nucleus and escape through the tear duct. In the meantime, Leela and K-9 fight off the infected staff of the hospital.
After a hazardous voyage through his mind, the Doctor's clone and Leela's clone are separated, and the Doctor's clone reaches the Nucleus. He has no weapons with which to destroy it, and it learns the intended escape route of the Doctor's clone, since the Doctor thought of it. Prof. Marius faithfully retrieves something from the tear duct and expands it to human size. It turns out to be the Nucleus. The Doctor is cured of his infection.
The Nucleus and the infected staff leave for Titan Base so the Nucleus can spawn. The Doctor realizes he is cured since Leela's clone introduced into his blood stream her immunity factor. He replicates it and gives it to Prof. Marius. The Doctor, Leela, and K-9 proceed to Titan Base in the TARDIS.
They just barely manage to fight off the infected humans, but are again without sufficient weaponry to destroy the Nucleus, or its many children which are about to hatch as "macro-sized" beings, like the newly macro-sized Nucleus. The Doctor manages to jam the door they are behind and rigs a gun to fire into a cloud of Oxygen gas he is releasing and escapes. As intended, when the Swarm finally forces open the door, the blaster fires, igniting the Oxygen in Titan's methane atmosphere and destroying the Swarm and the base.
When they return to the hospital, they thank Prof. Marius for the use of K-9, who has ably assisted them. Prof. Marius makes a surprising offer. He must soon return to Earth, and weight restrictions now prevent him from taking K-9 back. He offers him to the Doctor, with some sadness, but knowing K-9 will have a good home. The Doctor and Leela gratefully accept, and K-9 himself is eager to learn more about the TARDIS.
Prof. Marius, with teary eyes, watches the TARDIS disappear, commenting, "I only hope he's TARDIS-trained."
Doctor Tom Baker (Fourth Doctor)
Companions Louise Jameson (Leela)
John Leeson (K-9 Mk. I)
Michael Sheard — Lowe
Brian Grellis — Safran
Jay Neill — Silvey
Edmund Pegge — Meeker
Anthony Rowlands — Crewman
Frederick Jaeger — Professor Marius
Roy Herrick — Parsons
Elizabeth Norman, Nell Curran — Nurses
Jim McManus — Ophthalmologist
Roderick Smith — Cruikshank
Kenneth Waller — Hedges
Pat Gorman — Medic
John Scott Martin — Nucleus
Writer Bob Baker
Director Derrick Goodwin
Script editor Robert Holmes
Producer Graham Williams
Executive producer(s) None
Production code 4T
Series Season 15
Length 4 episodes, 25 minutes each
Originally broadcast October 1–October 22, 1977