The Doctor and Romana, after finding another part are about to embark in search of the third segment of the Key to Time when an aural warning tells them to "Beware the Black Guardian." At this prompt the Doctor reveals Romana was not sent on this quest by the President of the Time Lords, but rather by the omni-powerful White Guardian, who wishes them to gather the Key to maintain galactic stability. They venture outside to find themselves near the Nine Travellers, a group of gromlech or standing stones in Boscombe Moor, Cornwall. Also interested in the location is aged archaeologist, Professor Amelia Rumford, who is surveying the stones along with her friend, Vivien Fay.
Alerted to the activities of a local druidic sect, the Doctor heads off to meet its implied leader, de Vries, who lives in a large property nearby, Boscombe Hall, built on the site of the Convent of the Sisters of St Gudula. Inside, de Vries and his maid Martha are incanting to the Cailleach, the Druidic goddess of war and magic. The Doctor interrupts and is entertained briefly by de Vries until his host sees the opportunity to knock him out. De Vries and his mistress, dressed in a hideous bird costume, aim to sacrifice him to the Cailleach, but are disturbed by Professor Rumford, who helps the Doctor get free.
At the same time Romana is wandering by the cliff edge when an apparition of the Doctor confronts her and she nearly falls over the edge. When the real Doctor saves her she is somewhat confused, but the newly arrived K-9 calms her by assuring Romana it is indeed the Doctor – and he is convinced of the existence of a projected doppelganger. He determines that de Vries can answer some questions, and sets off for Boscombe Hall. When he gets there he finds the owner and his maid dead, crushed to death and the place under attack by a pair of mobile giant stones like those from the Moor. The Doctor and K-9 repel the attack, though the robot is badly damaged and needs repair work in the TARDIS. Some more curious facts come to life: the Doctor works out that the stones are depend on globulin and therefore need blood to survive; and Romana has pieced together that the owners of the Hall and the preceding convent were all women. It soon becomes clear they all had the same face too – that of Vivien Fay.
Meanwhile the woman in the bird costume has brought more stones (or Ogri, as she calls them) to life using poured blood. Romana ventures back to the stone circle and there finds Miss Fay in the costume. When challenged, she fires a weapon at Romana which sends her to hyperspace. After destroying one of the stones which is pursuing them, the Doctor and Professor Rumford reach the stone circle they are told by Miss Fay that Romana will be safe providing the Doctor stops interfering, and then disappears. The Doctor now identifies the stones as Ogri, a life form from Ogros in the Tau Ceti system, and there are two of them still missing and moving around the countryside. Two innocent campers help quench their taste for blood.
The Doctor calculates Romana and her captor must be in hyperspace, and builds a projecting device which he uses to transmit himself there. He arrives on a hyperspace craft which appears to be a prison vessel. He soon breaks a lock on a sealed door, releasing two floating globes. They are Megara, justice machines - dispensing the law as judge, jury and executioner. They contend that as the Doctor broke the seals he has transgressed the law and should be eliminated.
K-9 and Amelia have meanwhile been tasked with protecting the projector used by the Doctor to cross the dimensions, but find themselves under attack from two of the Ogri. Vivien returns to Earth and destroys the device but spares her friend. She takes the Ogri back to the hyperspace vessel with her and there tells the Doctor and Romana she has destroyed their linking device between the dimensions, leaving them trapped in hyperspace though she, with her wand, can cross the dimensions easily. The Megara destroy one of the Ogri when it threatens them.
The Doctor now faces trial by the Megara, an abrupt and unfair process dependent on the word but not the spirit of the law. Conducting his own defence, he attempts to draw Vivien Fay into the trial and to get the Megara to subject her to truth indicators, surmising she is one of the criminals from the prison ship. He finds out that one of the prisoners the ship was carrying is Cessair of Diplos, a criminal wanted for murder and the removal and misuse of the Great Seal of Diplos, which had the powers of transmutation, transformation, and the establishing of hyper spatial and temporal coordinates.
Amelia and K-9 have meanwhile repaired the projector and use the device to beam Romana back from the hyperspace vessel – plus the one surviving Ogri, which pursues them. They find some incriminating data at Miss Fay’s cottage and then Romana and the Ogri return to the spacecraft to await the verdict.
At the close of his trial, the Doctor is convicted and the Megara fire executing beams at him. He quickly drags Vivien into the beams’ focus, forcing the Megara to examine her to see if she is badly hurt. On doing so they find that she is indeed Cessair of Diplos. She is charged with her crimes when she awakes and the last Ogri is confined in a cell aboard ship to be returned to its own planet. Cessair is sentenced to confinement for 1500 years and perpetual imprisonment, both to run consecutively, and is turned into stone on Boscawen Moor.
After further questioning by the Megara on the matter of his delayed execution, the Doctor, K-9 and Romana return to the TARDIS, thanking Amelia for her great assistance. As he suspected the Great Seal of Diplos – removed from the Cessair’s neck before she was turned to stone - is the third segment of the Key to Time and he translates it to its proper form, and it leads to the next part of the story.