It has been an uncommonly warm winter in Middletown, and to some it seems like the end of the world. The tin mine has been worked out, and Lord Urton has bankrupted himself damming the river in the vain hope of exposing fresh seams of ore. A team of army engineers is called in to check the stability of the dam when earth tremors open up a deep fissure across the moors, and, concerned by the inexplicable events, Lord Urton calls on the Society of Psychical Research to investigate. A stranger named Roger Nepath then arrives in town, offering to purchase and reopen the mine -- but when Lord Urton accompanies him into the mine to see what has been exposed by the recent earth tremors, he emerges changed by the experience. He suddenly seems much colder and more distant to his friends, and allows Nepath to move himself and all of his belongings into the manor without question. When Professor Isaac Dobbs and young Alistair Gaddis from the Society of Psychical Research arrive, Lord Urton claims that their presence is no longer required, and Lady Urton is forced to intervene to prevent her husband from turning them out into the cold. Furious, she demands that Nepath leave her home and release his hold over her husband -- but instead, he introduces Lady Urton to his sister, and as she stares in horror, her husband clutches her face with burning hands...
When Reverend Matthew Stobbold arrives for his monthly dinner with the Urtons, he finds that Lady Urton is now claiming that there is no room for Dobbs and Gaddis to stay. They are joined at a rather tense dinner by Nepath, Dobbs and Gaddis -- and a stranger called the Doctor, who slips in so smoothly that everyone assumes he is there with someone else. Nepath scoffs at Dobbs’ scientific mind, claiming to have travelled extensively through the world and seen many things that cannot be explained. The Doctor in turn points out that the only way to make a profit on the mine is to save on labour by automating it, which means that Nepath will not be bringing back jobs as he claims. As dinner comes to a close, the Doctor claims to have been under the impression that Stobbold would house him while he stayed in Middletown, and Stobbold agrees to do so and also offers rooms to Dobbs and Gaddis. Nepath, put out by this slight to his hospitality, nevertheless gives Stobbold a present for his daughter Betty; a pendant depicting Agni, god of fire. While Stobbold takes his guests’ belongings to the rectory -- noting to his surprise that the Doctor doesn’t seem to have any -- the Doctor, Dobbs and Gaddis walk back, discussing Gaddis’ claim that he can sense, perhaps through subliminal signals, other people’s emotional states. He is getting nothing at all from Lord and Lady Urton -- but from the Doctor, he gets far too much. At the rectory, the Doctor and Stobbold spend the night talking about free will and responsibility, interrupted briefly when Betty sleepwalks into the living room, apparently seeking the warmth of the fire.
The next day, the Doctor accompanies Dobbs and Gaddis to the fissure, but when Gaddis suggests dowsing to search for lines of force emanating from the fissure, the irritated Dobbs leaves him to his own credulous devices. Gaddis, left alone, does in fact detect numerous lines of energy heading in the same direction -- but Lord Urton catches him and prevents him from telling anybody what he has found. Meanwhile, Colonel Wilson allows the Doctor and Dobbs to use the dam as a vantage point to get a better look at the fissure, but the Doctor is more interested in the water in the reservoir -- which seems to be warm and acidic, suggesting that there is a great source of heat beneath its surface. He and Dobbs return to the fissure, no closer to solving the mystery of its appearance -- only to find Gaddis’ body lying nearby, charred beyond recognition. Dobbs is horrified and grief-stricken, but the Doctor is merely fascinated by the discovery...
Over the next few days, Nepath sells off many artefacts which he has collected on his travels, apparently in a rush to fund the purchase of mining equipment. Claiming to be interested in funding Nepath, the Doctor attends a private auction at which Nepath sells off the more unusual items of his collection. The Doctor’s deliberate lack of interest provokes Nepath into inviting him to a private demonstration of his “memory mineral” -- a material which, when properly refined, retains its shape even after being destroyed. Nepath demonstrates by inviting Sir William Grant to smash a bird statue flat with a hammer; once the ruined statue is thrown into a fire, it absorbs the heat and reforms into the shape of a bird. Nepath offers to show Grant the military applications of his mineral -- a demonstration to which the Doctor is absolutely not invited, although Nepath does give him a sample of the mineral as a souvenir.
The Doctor returns to the rectory, to find that Dobbs has returned, seeking answers for his young friend’s death. Despite Stobbold’s objections, the Doctor and Dobbs decide to spy on Nepath’s demonstration the next day. With the aid of Colonel Wilson’s regiment, Nepath shows Grant a field gun made of memory mineral; although destroyed by a direct hit, it reassembles itself using the energy of the blast that destroyed it. Grant, impressed, gives Nepath a large cash advance, telling him to make more of the miracle guns for the army... and Nepath immediately purchases more mining equipment with it. As the Doctor and Dobbs return to the rectory, Dobbs finally asks the Doctor what drew him to Middletown, and the Doctor shows him a small box which the Doctor has carried for as long as he can remember. It recently began to glow red-hot, but only on the side pointing towards Middletown. Later that night, the “memory mineral” which the Doctor was given at Nepath’s auction erupts into a flow of molten lava -- and the lava is drawn into the Doctor’s box, which absorbs it and grows to the size of a man.
The Doctor and Dobbs break into Lord Urton’s manor to search for more clues, and find proof that Nepath has been using the memory material to make copies of the artefacts he sold at auction. They also find the long-dead body of a young girl preserved in a display case. Lord and Lady Urton then attack, and when the housekeeper gets in the way they incinerate her with a touch. The Doctor and Dobbs barely escape back to the rectory, but Urton contacts Stobbold and insists that he expel the “guests” who broke into his home. Stobbold, furious, demands an explanation from the Doctor, who storms off in rage when Stobbold will not take him at his word that there is evil at work in the village. Dobbs, however, then points out to Stobbold that whereas their footprints are merely compacting the snow, Urton’s have melted right through it to the ground. Stobbold apologises to the Doctor, who finally admits that he does not know who he is, or where he comes from.
Stobbold takes the Doctor to the church steeple, where they get a good look at the fissure and see lines of melted snow running from the fissure towards Urton’s mine. The Doctor asks Stobbold to send a telegram to London, asking about Nepath, and Stobbold delegates this to his daughter; Betty has been quiet of late, and he fears that he has been neglecting her and that she is too upset to tell him if anything is wrong with her. The Doctor and Dobbs, meanwhile, go to the mine to investigate, but the foreman Devlin accuses them of trying to shut down the mine and rob his men of their jobs. The Doctor and Dobbs, however, see flames dancing in Devlin’s eyes, and flee past him into the mine before he can burn them to death with his touch. There, they evade the angry miners and find their way to a new shaft, which the earth tremors have opened up. Beyond the shaft is a cavern filled with pools of molten lava -- the source of Nepath’s memory mineral and of the heat beneath the reservoir. The lava forms itself into humanoid figures, surrounding them, and the Doctor flees, abandoning the panic-stricken Dobbs, who is captured and burned to death.
The Doctor returns to the rectory, and tells the horrified Stobbold that Nepath has made a pact with some sort of elemental force which lives beneath the mine; a living magma with the ability to reshape itself into new forms. Already it has killed and replaced the Urtons and Devlin, but how much further is Nepath going to help it spread? The Doctor desperately needs an insight into Nepath’s motivations, but he soon realises that he will get no answer to his telegram -- for when Betty returns, claiming to have gone for a walk in the rain, she is perfectly dry. Ever since Stobbold gave her the living pendant of Agni, she has been acting as Nepath’s eyes and ears in the rectory. Betty plucks a burning coal out of the fire and directs the flames towards the Doctor and Stobbold, who flee into the garden. The rain has weakened the garden wall, and when Betty fires at the Doctor and Stobbold, her blast brings the wall down on her. The entire town is then rocked by an explosion, and the Doctor finally realises that Middletown is located in an ancient volcanic caldera -- and that a new eruption has just begun.
Wilson and his regiment have remained in town to collect the first consignment of Nepath’s new field guns, and they try to maintain order as the eruption hits. The Doctor runs into Wilson when he stops off at the local post office on his way to the Urtons’, and urges him to evacuate the town, claiming that this is only a precursor to a larger eruption to come. Wilson is unwilling to take such drastic measures without proof, and takes Sergeant Griffiths to the fissure to investigate; however, as they pass the mine, the lava men emerge and Devlin casts off his human guise, killing Griffiths. Wilson flees back to the town, orders his men to evacuate the townspeople, and sets up the field guns to destroy the advancing attackers. But these are the new field guns made of memory material, and instead of firing, they explode, slaughtering most of Wilson’s regiment. Wilson and the survivors retreat to higher ground as the remains of their guns flow back into the mass of molten magma now approaching Middletown.
The Doctor and Stobbold arrive at Lord Urton’s, where Nepath’s artefacts flow together into a large pool of molten magma which pursues them through the manor. Lady Urton and Nepath are waiting for them near the display case containing the corpse of the young girl. Nepath claims that the magma creature has run out of food beneath the mine, and that he intends to seed new areas of the Earth for it to feed on, and move in to restore order once it has passed on. The Doctor, however, knows that his motivations are far more personal than the pursuit of power; he suspected Betty some time ago and sent a second telegram himself. The dead young girl is Nepath’s sister Patience; when Nepath was a young boy he tarried too long watching a neighbour’s house burn, and it collapsed atop his sister when she came to collect him. He has blamed himself for her death ever since and believes that the creature can restore her to life. The magma in the shape of Lady Urton to reshape itself into Betty’s form, trying to enlist Stobbold’s help; however, Stobbold knows that this is not really his daughter, and he and the Doctor flee as the lava flows into Patience’s corpse, apparently restoring her to life.
The Doctor and Stobbold are attacked by Lord Urton as they flee from the manor, but the Doctor kicks him into the river, where the cold water freezes him into a stone statue which crumbles apart in the torrent. The Doctor has no choice but to release the water in the reservoir, but when he and Stobbold contact Wilson, the colonel is unwilling to blow the dam without orders; despite all he has seen, he still thinks the situation can be controlled and fears that flooding the valley could result in property damage and loss of life. The Doctor storms off to make one last attempt to talk sense into Nepath, while Wilson takes Stobbold and his men to the dam in case it does become necessary to destroy it. There, they find Grant waiting for them, and he orders them to stand down -- but he too has been consumed and replaced by the lava, and when Wilson refuses to accept his order, Grant attacks him. Captain Brookes gives his life to push the burning man over the edge of the dam, saving Wilson’s life. Now convinced that he must indeed act immediately, Wilson has his men lower a pack of explosives over the side of the dam -- as the magma flows upwards, trying to reach the pack and smother the explosion.
Nepath and Patience are now the lord and lady of the sulphurous volcanic wasteland that was Middletown, and they are waiting for the Doctor to return. Once again he tries to convince Nepath that he is deluding himself -- this is not his sister, and the elemental creature burned away what little remained of her corpse in order to convince Nepath that it had resurrected her. If it abandons her form, only an empty stone shell will remain. The Doctor manages to awaken a seed of doubt in Nepath’s mind, and he demands that his sister prove the Doctor wrong. Realising that he will not back down, Patience embraces him -- and the lava flows out of her body, leaving Nepath trapped in a statue’s embrace. At that moment, the flowing magma at the dam covers the explosives just as they go off -- but instead of smothering the explosion, this concentrates the power of the blast on one small part of the dam, and the water pressure on the weak point does the rest. As the dam falls apart the water floods into the caldera, reducing the living magma to harmless stone. As Nepath, locked in his stone sister’s arms, tries to struggle out of the rushing water, the Doctor seems about to lift him to safety -- but instead pushes him back into the water, and walks away as he drowns.
As the water subsides, Wilson finds that the upheavals have exposed fresh seams of tin ore; Middletown may not be finished after all. The Doctor packs up his mysterious blue box and prepares to leave, hoping that one day he will understand who he is and why he has been left a message to meet a man named Fitz in St Louis on February 2001. As the Doctor departs, Stobbold witnesses a miracle; his daughter was never consumed but only possessed by the burning, and she digs herself out from under the wall, still alive.