In the Middle Ages, the bandit Irongron and his aide Bloodaxe together with their rabble of criminals find the crashed spaceship of a Sontaran warrior named Linx. The alien claims Earth for his Empire then sets about repairing his ship, offering Irongron “magic weapons” that will make him a king in return for shelter. They strike a bargain, though Irongron remains suspicious.
The Doctor and Brigadier Lethbridge-Stewart are investigating the disappearance of several scientists from a top secret scientific research complex. They do not know Linx has used an Osmic Projector to send himself forward eight hundred years and has kidnapped the scientists then hypnotized them into making repairs on his ship. The Projector only lets him appear in another time for a brief period. While the Doctor investigates he meets an eccentric scientist called Rubeish and a young journalist called Sarah Jane Smith, who has infiltrated the complex by masquerading as her aunt. Later that evening Rubeish disappears and the Doctor uses the data he has gathered to pilot the TARDIS back to the Middle Ages, not realising new companion Sarah has stowed away on board.
Irongron has stolen his castle from an absent nobleman, and relations with his neighbours are appalling. Indeed, the mild Lord Edward of Wessex has been provoked into building an alliance against him and, when this is slow in developing, sends his archer Hal on an unsuccessful mission to kill Irongron. The robber baron is in a foul mood when a captured Sarah is brought before him. His mood improves when Linx presents him with a robot knight which is then put to the test on a captured Hal. The archer is only saved when the Doctor intervenes from afar, shooting the robot control box from Irongron’s hands. The ensuing confusion lets both Hal and Sarah flee, and they head for Wessex Castle.
Meanwhile the Doctor has realised both that Sarah is in the time period and has been captured, and also that she previously supposed him to be in league with Irongron. The next morning the robber baron and his troops assault the castle using rifles supplied by Linx but the attack is repelled by the Doctor’s cunning. The failure further sours the relationship between Linx and Irongron, which has deteriorated since the robot knight fiasco and the point at which the robber saw the Sontaran’s true visage beneath his helmet.
The Doctor now decides to lead an attack on Irongron’s castle, and he and Sarah enter dressed as friars. He makes contact with Rubeish and finds the human scientists in a state of extreme exhaustion. Linx catches the Doctor in the laboratory once more, but this time is rendered immobile when a lucky strike from Rubeish hits his probic vent – a Sontaran refuelling point on the back of their necks which is also their main weakness. Rubeish and the Doctor use the Osmic Projector to send the scientists back to the twentieth century. Sarah now invites herself into Irongron’s kitchen, using the opportunity to drug the food, thereby knocking out Irongron’s men.
A recovered Linx now determines his ship is repaired enough to effect a departure. Once more he encounters the Doctor, and they wrestle in combat. A crazed and half drugged Irongron arrives and accuses Linx of betraying him: the Sontaran responds by killing him. As Linx enters his spherical vessel Hal arrives and shoots him in the probic vent, and the Sontaran warrior falls dead over his controls, triggering the launch mechanism. Knowing the place is about to explode when the shuttle takes off, Bloodaxe awakes and rises the remaining men and tells them to flee, while the Doctor hurries the last of his allies out of the castle. It explodes moments before the Doctor and Sarah depart in the TARDIS.