During a storm that whips through the village of Devil's End in Wiltshire, a dog gets away from its owner. He pursues it into a graveyard, only to encounter something unseen and die. The local doctor says that it was a heart attack, but Olive Hawthorne, the local witch, insists that the man died of fright. She has cast the runes, and there is evil afoot.
Near the village, an archaeological dig is excavating the infamous Devil's Hump, a Bronze Age burial mound. The dig is being covered by BBC Three. The interviewer, Alistair Fergus, speaks to the cantankerous Professor Horner, who claims that the Hump holds the treasure and tomb of a warrior chieftain, and that he plans to open the tomb at the stroke of midnight on April 30, the pagan festival of Beltane.
The television coverage is being watched by the Third Doctor and Jo at UNIT. While the Doctor scoffs at Jo's notions of the coming of the Age of Aquarius and the supernatural, he feels that something is wrong with the dig. On the television, they see Olive go to the dig to protest, warning of great evil and the coming of the horned one, but she is dismissed as a crank. The Doctor tells Jo that Olive Hawthorne is right — the dig must be stopped, and they start off to Devil's End.
Olive returns to the village, and a strong wind whips up out of nowhere. She raises her hands to dismiss it, not knowing that the local constable, PC Groom, has gone into a trance behind her and is about to strike her with a stone. The wind dies down as she chants, and PC Groom regains his senses before he lands the blow. Olive then goes to see the vicar, but he has been mysteriously replaced with a new one, Mr Magister. Magister — actually the Master — tries to assure her that her fears are unfounded, but his hypnosis fails to overcome Olive's will, and she says she will find someone who will believe her.
The Doctor and Jo, driving to Devil's End, get lost when a wind spins a signpost and points them in the wrong direction. Over at the Hump, tempers start to flare for no reason. When the Doctor and Jo stop by the village pub to get directions, one of the villagers goes and informs the Master of the Doctor's presence. The Master tells him to get dressed for the ceremony.
On the way to the Hump, the Doctor's car, Bessie, is blocked by a fallen tree. Unable to budge it, the Doctor and Jo rush to the mound on foot. The Master, dressed in ceremonial robes and with a coven of thirteen acolytes, starts a summoning ritual in the church catacombs. As his chanting grows more frenzied, the Doctor and Jo reach the mound and the Doctor rushes inside to stop Horner, but it is too late. The tomb door opens and icy gusts of wind rush out and the ground begins to shake, toppling the camera crew and even the coven in the catacombs. The Master laughs triumphantly and calls the entity's name — Azal, and the eyes of a gargoyle, Bok, flare with a reddish glow. Jo enters the mound to find Horner and the Doctor motionless, covered with frost.
Horner is dead, and the Doctor seems dead as well. The Master uses a knife to indicate a stone covered in ritual markings as the "appointed place", dismissing the coven. Back at UNIT, Captain Mike Yates and Sergeant Benton were watching the end of the broadcast as it went dead. They try to find out what's going on while attempting to contact the Brigadier, who had earlier gone for a night at the opera. Meanwhile, the village doctor discovers that the Doctor may not be entirely dead after all, but is puzzled when he hears the beating of two hearts. Jo telephones Yates, who tells her he will be there by helicopter in the morning, just as the line is cut off from the outside. The Master prays in the church as Jo watches over the still unconscious Doctor in the pub. At the dig, the ground shakes and the constable on duty sees something gigantic with heavy footsteps, and falls.
In the morning, Yates and Benton fly by helicopter to Devil's End, and see burn marks on the fields before the village that resemble enormous footprints. Once in Devil's End, Benton decides to look around the village while Yates finally manages to contact the Brigadier, who is not pleased that Yates has commandeered his helicopter, and calls for a car. Benton, looking around in the church, finds Olive trapped in a cupboard, where the Master's verger, Garvin, had locked her. Down in the cellar to hide from Garvin, she tells Benton about Magister. Garvin comes down with a rifle, and Benton tries to disarm him. In the ensuing fight, Benton falls on the marked stone and seizes up. Garvin holds both of them at gunpoint and moves them outside, just as the ground starts to shake. Garvin fires up at something gigantic, but is engulfed in a fireball. The heat wave extends even into the village, knocking Jo and Yates down, just as the Doctor awakens with a start. Olive and Benton make their way back to the pub, and the Doctor discusses the incident with Olive, who says that she saw the devil, 30 feet high and with horns. The Doctor is told of the new vicar, and realises who is behind this, as "Magister" is Latin for "Master".
The Brigadier finds himself unable to enter the village, as there is a barrier surrounding it that causes anything trying to enter to heat up and burst into flame. He contacts Yates and is briefed on the situation while the Doctor and Jo return to the dig, an act the Master seems to be able to sense. They find the constable dead and a small spaceship in the mound the same shape as the Hump. Jo tries to lift it but cannot, as the Doctor explains that it weighs 750 tons. Suddenly, Bok leaps into the tent covering the entrance to the tomb, about to attack.
The Doctor wards him off with some words in a strange language and an iron trowel. The Doctor explains to Jo that it was actually the words of a Venusian lullaby — it was the gargoyle's own superstition that drove it back.
The Master, in the meantime, hypnotises the squire, Winstanley, as Olive and the Doctor debate about whether it is magic or science that is at work here. The Brigadier discovers that the heat shield is dome shaped, centred on the church, with a radius of ten miles out and one mile high. The Doctor shows the others pictures of various horned gods and demons from Olive's occult and history book collection, and explains that the creature Olive saw was an extraterrestrial, one of the Dæmons from the planet Dæmos, 60,000 light years away, who came to Earth one hundred thousand years before. The small spaceship's actual size is 200 feet long and 30 feet across, and the heat and cold waves they have been experiencing are the result of the energy displaced when the ship shrinks or grows. The Doctor further explains that the Dæmons have influenced Earth throughout its history, becoming part of human myth, and see the planet as a giant experiment. The Master has called the Dæmon up once, and right now, it is so small as to be invisible. The third summoning, however, could signal the end of the experiment, and the world.
The Brigadier contacts Yates and says he is about to try attacking the heat shield from the air. The Doctor warns him not to, saying that it would only strengthen it, and suggests they use a diathermic energy exchanger. When UNIT technician Osgood fails to understand what the Doctor is getting at, he says he will come out and explain. When he does so, Tom Girton, one the villagers working with Master, hijacks the UNIT helicopter and uses it to attack the Doctor. The Doctor manages to swerve Bessie out of the way and the helicopter explodes against the heat shield. As the Doctor relates his instructions to Osgood, who protests that it goes against the laws of physics, the Master summons Azal again. A heat wave and an earth tremor once again sweeps through the village as Azal curses the Master for daring to summon him again.
The Master tries to dismiss Azal with an iron candlestick holder, but it does not seem to work. He demands that Azal give him the power that is his right, but Azal warns him that he is not the Master's servant. Azal also senses the presence of another like the Master, and wants to speak to the Doctor to see if he is worthy to take over the world. Azal says on his third appearance, he will decide if Earth deserves to continue existing. If so, he will give it to the Master. Azal then vanishes in another heat wave.
After explaining the process of creating the exchanger to Osgood, the Doctor returns to the village. However, the Master's agents are at work, and he is soon captured by a mob of villagers and tied up to a maypole, about to be burned alive. Olive goes to the mob and tells them that the Doctor is a mighty wizard, and with some help from Benton's silenced Pistol and a remote controlled Bessie, convinces the mob that the Doctor does indeed have magical powers. Jo and Mike, meanwhile, have returned to the church cellar and watch, hidden, as the Master gathers his coven to summon Azal one last time. Jo tries to interrupt the ritual, but it is too late.
With another rush of heat, Azal manifests himself and Jo and Yates are taken prisoner. Outside, the Doctor explains that to the now calmer villagers that his "magic" was due to science, and so is the Master's trickery. The rituals are merely used to focus the psychokinetic energy of humans that the Master needs to summon the Dæmons. As Jo is prepared as a sacrifice to Azal, the exchanger finally works and UNIT forces go through the gap created in the heat shield, but the gap only lasts a few minutes and the exchanger soon overloads. Mike manages to escape and tell the Doctor about Jo, but Bok is guarding the entrance to the catacombs. The use of the exchanger momentarily weakens Bok and Azal, and the Doctor manages to rush by the gargoyle. He makes it down to the cellar, where the Master is expecting him.
Outside, UNIT troops start firing at Bok, who can disintegrate objects and people with a wave of his hand, but he is also bulletproof. Even a bazooka does not work, as the pieces of the gargoyle reform almost instantly. Inside the church, the Master makes his case to the Dæmon that he will rule the Earth experiment's people for their own good. The Doctor argues that Man should be given a chance to grow up. Azal finally decides to give his power to the Master, and fires electricity at the Doctor to kill him. However, Jo, steps in front of the Doctor, asking Azal to kill her instead. This act of self-sacrifice does not make sense to Azal, and the confusion sends him into an agony. He shouts for all of them to leave as he is dying. Bok reverts to his stone form, and as everyone runs out of the church, it blows up. The Master tries to escape in Bessie, but the Doctor's remote control brings the car back, and the Master is taken into custody, to be put in maximum security.
Olive Hawthorne hears the sound of bird songs and the smell of flowers once again, as the Earth is reborn each May Day. Olive takes Benton to dance around the maypole with the rest of the townsfolk, while Yates and the Brigadier go off to the pub for a drink. The Doctor and Jo join the dance, as the May Day celebrations continue and the Doctor remarks to Jo that perhaps there is magic in the world after all.