Following on from Planet of the Spiders, Sarah Jane Smith and the Brigadier watch as the Third Doctor's features fade into that of the Fourth Doctor. The newly regenerated Doctor is delirious, waking up to spout random lines from past adventures before falling unconscious again. The Brigadier summons the base medical officer, Lieutenant Harry Sullivan to take the Doctor to sickbay and care for him.
Meanwhile, something large and mechanical enters a Ministry of Defence advanced research centre, killing a guard and breaking easily through a gate before stealing some documents from a vault. In the Doctor's laboratory, the Brigadier confides to Sarah that the plans are that of a disintegrator gun. Sarah asks the Brigadier if he could arrange for a visitor's pass to the National Institute for Advanced Scientific Research, or "Think Tank", which only admits journalists rarely. The Brigadier is glad to help, and the two leave for his office, just as the Doctor sneaks into the laboratory. Finding the TARDIS locked, the Doctor manages to discover the key in one of his boots. Before he can enter his ship, however, he is interrupted by Harry, who tries to persuade him to return to sickbay.
When Sarah and the Brigadier return to the lab, they find Harry shut up in a locker, and hear the wheezing sound of the TARDIS starting to take off. Sarah bangs frantically on the police box, causing the Doctor to pop his head out. Sarah tries to coax the still unstable Doctor out of the TARDIS by saying that they need his help to find a stolen secret weapon. She almost fails, until the Doctor finally recognises her and the Brigadier.
The mechanical creature breaks into another facility, this time stealing some components from a vault. The Brigadier brings the Doctor to investigate the break-in, but the Doctor seems more interested in a pulverised dandelion on the grounds. He points out that the amount of force needed to do that would have to be about a quarter ton. He also deduces from the stolen items that whoever is doing this is stealing the components of a disintegrator gun. The last component is a focusing generator, and the Brigadier orders the factory where it is housed to be guarded immediately.
Sarah goes to visit Think Tank, where she is shown around the grounds by the director, Hilda Winters and her assistant, Arnold Jellicoe. Think Tank is a pure research facility — once the research reaches a certain stage, it is handed off to another organisation with more resources, like the government. In fact, the initial work on the disintegrator gun was done by Think Tank. Sarah notices a door marked "No Admittance" and pushes her way through into the former robotics section run by Professor J.P. Kettlewell. She remembers that Kettlewell left Think Tank after he turned against conventional science, and now works on alternative energy facilities. Sarah nearly slips on a wet patch on the floor as she looks around. Jellicoe insists, however, that there is nothing in the section, and he and Winters escort Sarah out.
At Emmett's Electronics, UNIT sets up barriers on all sides, but the Doctor observes that they have covered all directions... except down. Sure enough, the mechanical thing tunnels upward into the vault where the generator is kept, and by the time the others arrive, all that is left is a dead guard and a hole in the floor. At the other end of the tunnel in the woods, Sergeant Benton discovers a giant, rectangular and very deep footprint.
Sarah goes to see Kettlewell, who brusquely tells her that Think Tank cannot be carrying on his robotics research because no one else has the ability to do so. Still suspicious, she drives back to Think Tank and sneaks back into the robotics section, discovering that the wet patch was actually oil. At that moment, a set of doors opens, and a giant, gleaming robot lumbers towards her menacingly, demanding to know who she is what she is doing here.
Sarah runs, panicked, out where she came in and meets Winters. The director explains that since Sarah was so insistent on seeing what was in there, they activated the robot as a joke. In response to Sarah's questions, the robot identifies itself as Experimental Prototype Robot K1, its purpose being to replace human beings in carrying out hazardous activities like mining or handling radioactive materials. Sarah asks if the robot can be dangerous, and Winters demonstrates by ordering K1 to kill her. K1 is unable to do so, and the conflicting impulses cause it distress. Jellicoe explains that K1's prime directive is to serve and not harm humanity. Sarah observes that that was a cruel demonstration, and apologises to K1 for its distress, despite Winters claiming that the robot has no feelings. When Sarah leaves, Jellicoe tells Winters that the demonstration was dangerous, as K1's programming had just been reset.
Jellicoe and Winters adjust K1 again in preparation for sending it out. They show K1 a picture of Cabinet Minister Joseph Chambers, telling it that Chambers is an enemy of humanity. Meanwhile, Sarah reports what she has seen to UNIT. Unfortunately, the Brigadier cannot act without more evidence, so they decide to send Harry into Think Tank, undercover, to gather information. The others go to see Kettlewell, who is hostile at first but warms up when the Doctor shows interest in his work. Kettlewell tells them that he reluctantly ordered K1 dismantled because its capacity to learn and its power began to frighten him. He scoffs at the idea that Winters or Jellicoe would have the ability to alter the robot's programming, but concedes that if they had, it would drive the robot mad.
K1 enters Chambers' home, kills him and then disintegrates the door of his safe, stealing a set of documents. At UNIT, the Brigadier has discovered that many Think Tank scientists, including Winters and Jellicoe, belong to the Scientific Reform Society, a fringe group advocating a society ruled by a scientific elite. K1 arrives at Kettlewell's lab in a confused state and knowing it has been forced to go against its programming. It asks its creator for help. When the Doctor and the Brigadier go to Think Tank, Winters tells them that K1 has been dismantled, but Winters is aware that the Doctor knows she is lying. At the same time, Harry arrives at Think Tank in the guise of a medical inspector.
Alone in his lab, the Doctor receives a call from Kettlewell, who tells him about K1's presence. The Doctor agrees to go over, but leaves a note tacked up on the TARDIS in case it is a trap. Indeed, after Kettlewell hangs up, Winters and Jellicoe enter the professor's lab. When the Doctor arrives, he finds the place empty except for K1, who has been ordered to kill the Doctor as an enemy of humanity. Although the Doctor tries to get away, it manages to knock him out. K1 raises its arm to deliver the coup de grace.
Before K1 can land the killing blow, Sarah (having read the note) arrives. K1 recognises her as the person who showed concern for its wellbeing, and when Sarah tells it that Think Tank are deceiving it, K1 flails about in confusion and distress. At that moment, Benton and a squad of UNIT soldiers arrive, but it easily shrugs off their gunfire and escapes. They find Kettlewell tied up inside a cupboard and take him back to UNIT headquarters. There, he confirms that Jellicoe and Winters altered the robot's programming and made it unstable. He explains that K1 is made of a living metal he invented, one that can grow like a living organism. That also led him to another discovery, a virus that could biodegrade metal into a recyclable form.
When Sarah discovers that Kettlewell is still a member of the Scientific Reform Society, she persuades him to attend that evening's meeting and let her in secretly. When Benton protests, she points out that neither she nor Kettlewell are under UNIT's jurisdiction and the two leave. When the Doctor wakes up, he has realised that Chambers must have had access to some kind of ultimate threat. The Brigadier explains that some months before, to ensure peace, the governments of Russia, China and America decided to give the locations and launch codes of their nuclear weapons to a neutral country — Britain — for safekeeping, with the intention that Britain could publish these codes if war was imminent and allow things to cool down. Chambers was holding on to these Destructor Codes, and if Think Tank has them, they could hold the world to ransom. When Benton tells them that Sarah has gone off with Kettlewell, the Doctor is alarmed.
At the SRS meeting, Kettlewell opens a side door to let Sarah in. She hides in the meeting room as Winters addresses the membership, ranting that soon they will rule as is their right. To Sarah's shock, she credits this to one man: Kettlewell, who joins them on stage, as does K1. The robot senses Sarah's presence and homes in on her, just as the Doctor arrives to provide a distraction. He knew Kettlewell was the only one capable of altering K1's programming; the attack on him was a ruse to gain UNIT's confidence. Kettlewell explains that for years he had tried to persuade people to stop destroying the environment. Now with Think Tank, he can make them stop instead. The Doctor points out that in science, as in morality, the ends never justify the means, and Kettlewell gets an inkling of Winters' ruthlessness when she orders the Doctor and Sarah killed.
UNIT arrives at that moment, but using K1 as cover and Sarah as a hostage, Winters, Jellicoe and Kettlewell make their escape. Harry contacts the Brigadier from Think Tank, reporting that the scientists are evacuating to a bunker, but is knocked unconscious and taken captive before he can relate any more. UNIT troops proceed to Think Tank's atomic shelter, but are held off by its automated defences. Winters contacts the Brigadier: they have already given the governments of the world their demands. Unless these are agreed to, in full, in thirty minutes, she will use the Destructor Codes.
Benton and his men knock out the bunker's machine gun nests while the Doctor uses his sonic screwdriver to detonate the mines surrounding the entrance. Winters sends K1 out, armed with the disintegrator gun, which he proceeds to use on a soldier, and then a UNIT tank. It warns that it will destroy them all.
In the bunker, Winters gets Kettlewell to make the international computer linkups so they can use the Destructor Codes. Kettlewell still believes Winters is bluffing, but she disabuses him of the notion, telling him that if the world governments do not give in, she will fire the missiles. The countdown begins.
Kettlewell has a change of heart and tries to stop the countdown, but Jellicoe pulls a gun on him. However, Harry and Sarah have escaped their bonds and Harry knocks Jellicoe to the ground. Kettlewell holds the countdown while the other two open the doors. As they exit the bunker, K1 swings the disintegrator gun on them. Sarah tries to convince K1 again that Think Tank are evil. K1 struggles with the dilemma and fires the gun, disintegrating Kettlewell. With a wail of despair, the robot cries out that it has killed its creator, and collapses. With K1 apparently disabled, the Doctor and the UNIT troops make their way into the bunker.
Winters has resumed the countdown, and although she moves away from the console when ordered to, she is confident that no one can stop the countdown in time. However, she has not reckoned on the Doctor, who is able to reprogram the computer and cancel the order. However, in the mop-up, nobody notices that K1 has revived, and has taken Sarah with it into the bunker. The Doctor realises that K1 is in a state of emotional shock after killing its "father" and has developed an Oedipus complex. K1 intends to carry out Kettlewell's last orders and ensure the destruction of humanity, although the robot assures Sarah that she alone will be saved.
Benton tells the Doctor about Kettlewell's description of the robot's living metal and the accompanying virus he developed. The Doctor is delighted at the information and tells the Brigadier to find the robot while he and Harry go to Kettlewell's lab to cook up a batch of the virus. K1 locks the bunker and restarts to countdown. However, this time, the world governments' fail-safe procedures are activated in time, and the missiles remain unfired.
As K1 exits the bunker, the Brigadier fires at it with the disintegrator gun. However, instead of being destroyed, the robot starts to grow to gigantic size. It picks up Sarah like a doll and heads towards the nearby village. It places Sarah on a rooftop as a pitched battle takes place between K1 and the UNIT troops while the Doctor races back with the virus. Driving by K1's feet in his roadster, Bessie, the Doctor throws the batch of the virus at it. The virus instantly starts to spread across the robot's body, throwing its growth mechanism into reverse. It shrinks down to doll size, and then dissolves completely.
Back at the Doctor's laboratory, Sarah is still saddened at K1's demise. She realises that the Doctor had to do what he had to do, but it had seemed so human. The Doctor observes that it was capable of great good as well as great evil, so one could say that it was human. He suggests a trip in the TARDIS to cheer Sarah up. She agrees, just as Harry enters asking where they are going. When the Doctor tells him, Harry considers the idea that a police box can go anywhere an absurd idea. The Doctor then invites Harry to step inside to, just to prove that it is an illusion.
Harry steps into the TARDIS, and is heard to exclaim in surprise. The Doctor and Sarah follow, grinning. Once they enter, the TARDIS dematerialises just as the Brigadier comes in. Seeing the empty corner of the lab, the Brigadier muses to himself that he will have to tell Buckingham Palace that the Doctor will be a little late for dinner.
Doctor Tom Baker (Fourth Doctor)
Companions Elisabeth Sladen (Sarah Jane Smith)
Ian Marter (Harry Sullivan)
Nicholas Courtney — Brigadier Lethbridge-Stewart
John Levene — Warrant Officer Benton
Edward Burnham — Professor Kettlewell
Patricia Maynard — Miss Winters
Alec Linstead — Jellicoe
Michael Kilgarriff — The Robot
Timothy Craven — Short
Brian Fellows — Soldier
Writer Terrance Dicks
Director Christopher Barry
Script editor Robert Holmes
Producer Barry Letts
Executive producer(s) None
Production code 4A
Series Season 12
Length 4 episodes, 25 minutes each
Originally broadcast December 28, 1974–January 18, 1975