China, 1863. Two warrior monks and their abbot encounter a party of bandits sheltering from a storm in an underground cave in which mercury is impossibly flowing along the ceiling, and do battle when the bandit leader, Cheng, refuses to give himself up for justice. By the end of the fight the monks are the only ones standing -- and the strange power which then ripples through the mercury thus flows into the monks’ bodies, causing their eyes to glow brightly. As the bandits flee from the cave in terror, Cheng sees that a lunar eclipse is just ending.
Two years later, young Wong Fei-Hung and his lover visit an abandoned temple near the mountain of Baiyung for a secret tryst, but are frightened off when the TARDIS materialises before their eyes. The Doctor and his companions wait until morning to explore their surroundings, and a brisk walk soon takes them to the city of Guangzhou. There, they assume that they are attracting hostile and suspicious glances because they’re Western -- but when they stop in for lunch at an inn called the Hidden Panda, a drunken patron accosts Ian, calling him “Chesterton”, and he and his friends begin to beat him to within an inch of his life.
Elsewhere, a British army major suffers concussion while fighting bandits at the village of Qiang-Ling. As the concerned Sergeant-Major Anderson and Captain Richard Logan tend to his injuries, the major realises that he can no longer remember who he is. From the context, he gathers that he and his men arrived too late to prevent the bandits from razing the village to the ground, and the Qiang-Ling militia are angered by the British army’s failure to protect their Chinese subjects. Fearing that he will be discharged if the full extent of his injuries is known, the major does not reveal that he is now suffering from partial amnesia.
Fei-Hung tells his father, Wong Kei-Ying, about the strange incident at the temple, and Kei-Ying, though sceptical, agrees to investigate. Unsure what to make of the TARDIS, Kei-Ying decides to confer with Cheng, the owner of the Hidden Panda and former bandit leader, who sometimes conducts black market deals with the British. At the Hidden Panda, the Wongs find the mob beating Ian to death, and Kei-Ying intervenes though he’s also heard bad things about this man, Chesterton. Ian is unconscious and has several broken bones, but the Doctor recognises the Wongs from folk tales and accepts Kei-Ying’s offer to treat Ian’s injuries at his surgery, Po Chi Lam. The Doctor, already disturbed by this apparently unprovoked attack, is even more disturbed to learn that Ian has apparently already been in Guangzhou for over a year, and warns Kei-Ying not to send Ian back to the British garrison on Xamian Island until the Doctor has learned more.
Po Chi Lam is both a surgery and a gungfu school, and Kei-Ying’s deputy, Jiang, belongs to the Black Flag militia, as does Cheng -- but Cheng is horrified when the new head of the local militia is revealed to be the abbot from the underground cavern. The Abbot kills Lei-Fang, the former head of the militia, when Lei-Fang hesitates to obey an order, and the terrified Cheng retreats to the Hidden Panda after swearing undying loyalty to the Abbot. The Abbot orders Jiang to bring together all of the country’s alchemists, priests and astrologers, and to kill the false teachers who support the foreign invaders. Jiang sees an opportunity to curry favour with the Abbot -- and gain control of Po Chi Lam by ridding himself of Wong Kei-Ying.
Despite Kei-Ying’s best efforts, Ian’s injuries become infected, and the Doctor thus gives Barbara the TARDIS key and instructs her to fetch more technologically advanced medical equipment. Vicki offers to accompany her, to see more of city, and Kei-Ying orders Fei-Hung to escort them, though his son is wary of travelling during yuelaan jit, the Festival of Hungry Ghosts. On their way back to the temple, it begins to rain, and despite Fei-Hung’s reservations, Barbara and Vicki seek shelter in a small hut -- where the ghost of a mourning woman appears before their eyes. The three run from the bungalow and don’t stop until they’ve reached the TARDIS.
In the British barracks on Xamian Island, Logan reports to the injured major, who tries not to reveal the extent of his injuries. The recent bandit attacks are too well-organised to be random, but Logan believes that the Black Flag are interested only in overthrowing the Manchu dynasty and are not responsible for these violent attacks on ordinary villages. Jiang then arrives and claims that Wong Kei-Ying is holding a group of European travellers against their will at Po Chi Lam, and the soldiers set off to investigate. Cheng has been trading black market vodka to Sergeant-Major Anderson for ammunition, and he thus learns of the soldiers’ intentions in time to warn Kei-Ying. The Doctor offers to speak on Kei-Ying’s behalf, but Kei-Ying, fearing that the situation will become worse if the soldiers see the gravely wounded Ian, advises the Doctor to remain hidden lest he be regarded as a traitor. The Doctor hides and watches as the soldiers arrive, and though Kei-Ying offers up an explanation, it is an unbelievable one -- for Kei-Ying claims to have been treating the major himself, who’s spent the last night in the barracks on Xamian island. Indeed, the major appears to be an older Ian Chesterton.
Major Chesterton has little choice but to arrest Kei-Ying, but does allow him to make preparations so Po Chi Lam can function without him. Kei-Ying seems suspicious of Jiang, and in any case does not believe he is ready to run Po Chi Lam; he thus asks the Doctor to take charge of the surgery until his return, while his son deals with the gungfu school. This does not go down well with Jiang, who angrily challenges the Doctor to fight a duel with him; as is traditional, if he is indeed to be the master of Po Chi Lam, he must prove his worthiness.
Barbara returns with the medical equipment from the TARDIS, and the Doctor heals Ian’s injuries; however, he refuses to leave until the business of Kei-Ying’s false arrest is sorted out. He rejects Ian’s offer to fight the duel with Jiang on his behalf, and indeed, seems to be looking forward to it. However, he is also concerned by the presence of the older Chesterton; it seems that Ian will return to this era in his personal future, but if this is the case, what of the older Doctor, Barbara and Vicki? The Doctor is also intrigued when Barbara and Vicki claim to have seen a ghost, and suggests that they observed a “stone tape” effect, in which mental impressions are recorded in the architecture of a building in much the same way that sounds are recorded on oxide tape.
Fei-Hung visits Cheng to reschedule the Black Flag training classes while his father is in prison, and finds Cheng and his bouncer Pang trying to decide what to do about the possessed monks. From Cheng’s drunken explanations, Fei-Hung gathers that Jiang has challenged the Doctor in order to gain power within the Black Flag. Meanwhile, Jiang reports to the Abbot -- whose eyes glow with an inner light when Jiang claims that a stranger called the Doctor has arrived at Po Chi Lam, accompanied by foreigners in strange clothing. The Abbot orders Jiang to kill the Doctor.
Though he’s had to arrest Kei-Ying, Major Chesterton nevertheless senses that he’s an honourable man, and asks why he’s regarded with such hostility. Kei-Ying explains that his people believe that the British are not doing all they can to protect them from the frequent bandit attacks. The Doctor arrives to visit Kei-Ying and speak with Major Chesterton, but is disappointed to learn that the major recently suffered a concussion and cannot remember much of his past. The Doctor supplies Chesterton with herbs which will ease his pain, and promises to keep his secret; indeed, Chesterton’s memories slowly begin to return as his concussion subsides. Meanwhile, Ian recovers his strength and accompanies Barbara to the bungalow where she saw the ghost, and there, Barbara admits to Ian that she loves him.
The Abbot’s army seizes a small fishing village and razes its Buddhist temple. His two generals, Zhao and Gao, then bring three astrologers before the Abbot, who orders them to calculate the precise date and time of a forthcoming conjunction. One of the astrologers, Ko, catches a glimpse of the Abbot, Zhao and Gao standing together, an unearthly light streaming in and out of their eyes and mouths; he tries to flee, but Zhao pursues him and incinerates him with a blast of light from his hand.
Po Chi Lam continues to run smoothly under the Doctor’s guidance, but soon the time comes for his duel with Jiang. Despite their reservations, the Doctor’s friends stand back and let him accept the challenge on his own -- and, as the Doctor had predicted, the arrogant Jiang is unprepared for the Doctor’s way of fighting, as the Doctor uses his body as a fulcrum to divert Jiang’s direct attacks. At a crucial moment, the Doctor ducks aside from a devastating kick, and Jiang sprains his foot against a thick wooden support beam, thus losing the duel. Jiang flees and reports his failure to the Abbot, who orders Jiang to tell him what he -- the man whom the Abbot believes himself to be -- looked like in life. When Jiang gives the Abbot the answer he thinks the Abbot is expecting, rather than the truth, the Abbot blasts him down with a bolt of lightning from his hand and leaves him to die slowly.
Cheng asks Anderson for permission to speak with Kei-Ying, and eventually must admit that there is a schism brewing within the Black Flag. Anderson has Cheng tell his story to Major Chesterton, which he does, though glossing over the more unbelievable details about the Abbot. Logan points out that Cheng’s story might explain why Jiang turned in his own master, and Major Chesterton thus agrees to let Kei-Ying write letters summoning the eight surviving Tigers of Kwantung together to face this threat. Once Kei-Ying has done this, Major Chesterton releases him, now believing that Jiang’s story was nothing but lies.
As the staff and students of Po Chi Lam celebrate Kei-Ying’s return, Cheng tells his story once more, and this time tells him everything. Disturbed, the Doctor visits the British garrison at Zhenhailou to use their telescope. Ian accompanies him, despite the Doctor’s concern that Ian might accidentally come into contact with his older self; the other British soldiers assume that Ian is Major Chesterton’s younger brother. The Doctor, meanwhile, determines that the Earth is about to enter a particular stellar conjunction for the first time in 2000 years.
The Abbot hears that Major Chesterton’s brother has arrived in Guangzhou, and decides to get rid of Major Chesterton by kidnapping Barbara and using her as leverage to make Ian kill the Major. Four cloaked figures thus attack Po Chi Lam and make off with Barbara and Vicki, easily defeating the surgery’s defenders -- including two of the Tigers, Iron Bridge Three and Tham Chai Wen, who have just arrived. Their blows have no effect on the attackers, who seem to be wearing armour. The Doctor and Ian arrive too late to help, but the Doctor deduces that the Abbot was responsible; if so, there’s nothing he or Ian can do until they hear from the kidnappers. The Doctor thus continues his investigation into the recent bandit attacks, and concludes that the army has been attacking monasteries and other sacred locations -- and this year, even for yuelaan jit, there have been an extraordinary number of ghost sightings such as Barbara’s.
The Doctor demonstrates the nature of the threat to his friends, using lenses to refract and focus a beam of sunlight on a specific area of a grapefruit. In much the same way, alien intelligences far from the Earth require certain stellar conjunctions to generate an influence on Earth. The Doctor calculates that the focus of the alien transmission will be the sacred mountain of Xi’an, and indeed, Kei-Ying and Major Chesterton have plotted the bandit attacks backwards to determine that this is where the Abbot first began his mysterious crusade.
Barbara and Vicki are brought before the Abbot, who identifies himself as Qin Shi Huangdi -- the first Emperor of China, who died over 2000 years ago. Qin claims that he and his two most trusted generals survived the deaths of their bodies and have been reborn, but Barbara fears that he is just a madman who believes himself to be the Emperor. Privately, however, Qin has been suffering from doubts, as he finds his memories are unreliable. When he asks Barbara what he used to look like, she answers honestly despite the risk of offending him, and he decides to let her live, though Vicki remains expendable. Meanwhile, Gao visits Po Chi Lam and delivers a warning to Ian: if he does not kill Major Chesterton by the end of the day tomorrow, Barbara will be killed. The Doctor takes this warning as a good sign, firstly that he and his friends pose a legitimate threat to the Abbot, and secondly that Barbara and Vicki are still alive.
Barbara and Vicki privately discuss the Abbot’s insane claim, and wonder if Qin somehow recorded his mind into a “stone tape” such as the Doctor mentioned earlier. Qin overhears them speaking, but as he confronts them, his eyes glow with light and an alien voice speaks through his mouth, identifying Barbara as a time traveller and offering her dominion over the world if she agrees to serve this alien force.
Qin then returns to normal and speaks privately with Barbara, confessing that his resurrection is not as he expected. Disturbed, he sends her back to her cell, but she tricks the guard, allowing Vicki to escape. Qin is furious, particularly when Barbara speaks of a son whom he had forgotten. Perhaps he is not Qin at all, but a poor copy of the real man’s memories. Before Qin can order his generals to kill Barbara for putting these doubts in his mind, however, the alien force takes possession of him and stops him from doing so. The two surviving astrologers then complete their work, and inform Qin that the conjunction will begin shortly. Qin and his generals fire bolts of light from their hands, splitting a hole in the air and enabling Qin to walk through to the other side, taking Barbara with him.
Vicki evades Qi’s soldiers and returns to Po Chi Lam, with the help of Soh Hut Yi, another of the Tigers. There, she tells her story to the others, and the British agree to join forces with the Tigers against this strange Abbot. Fei-Hung offers to scout out the village before the attack, but he finds it deserted -- apart from Zhao and Gao, who are lying in wait at the monastery. Fei-Hung does battle with them, but just as he appears victorious, the generals begin to fire bolts of light from their hands. Fei-Hung evades this strange attack, and Zhao accidentally strikes Gao, burning his face off. Fei-Hung grabs Gao’s sword and pierces Zhao’s hand just as he fires another bolt, and all the alien energy in Zhao’s body is earthed out through the steel. Zhao collapses, and Gao, still moving despite his horrific injuries, opens up another rift in the air and flees.
Zhao has recovered by the time the Doctor and his friends arrive, but he claims to be a monk named Yeung, and remembers nothing after fighting the bandits in the underground cave. The Doctor and Kei-Ying mix a potion that sends Yeung into a hypnotic trance, and determine that he still retains some secondary memories of his possession. The Doctor puts together what he’s learned and deduces that Qin tried to become immortal by recording his personality in a “stone tape,” and, in effect, transforming himself into an executable programme which is now running in the Abbot’s brain. But the “Qin” programme has been rewritten by an alien force which is now using him and his generals as pawns to pave the way for an invasion.
To Ian, all considerations other than Barbara’s safety are secondary; and he thus decides that he must kill his older self in order to ensure that Barbara lives. By the time the Doctor realises that Ian has gone, it’s nearly too late -- and when he learns that Major Chesterton’s first name is actually William, he realises that he’s made a terrible mistake. Fortunately, he and his friends make it back to Xamian before Ian, and when the Doctor catches a glimpse of Gao watching proceedings, he decides to feed him misinformation. He thus arranges for a soldier to stop Ian at the gate, “mistaking” him for Major Chesterton, and present him with a pistol which Ian uses when the real Major emerges from his quarters. Gao retreats, satisfied, and unaware that the pistol was loaded with blanks and that Major Chesterton was in on the charade. The Doctor then informs Ian of the Major’s real identity, and Ian learns that he nearly killed his own great-grandfather.
Qin’s army has gathered outside the Emperor’s tomb, the cavern that Cheng and his bandits stumbled into two years ago. Though Qin believes that Ian has carried out his orders, and he thus has no further need of Barbara, he does not kill her, presumably because the alien force still has need of her -- or possibly because some part of him needs her approval and understanding. Inside the tomb, Qin shows Barbara his own burial chamber, and the army of terracotta warriors which will do his bidding throughout the land; Barbara was kidnapped from Po Chi Lam by four of the warriors, which had already been animated.
The Doctor calculates that more alien energy will be transmitted to Earth at the moment of total lunar eclipse as seen from the summit of Xi’an. Those who haven’t seen the unearthly monks remain sceptical of the Doctor’s wilder claims, but agree that the Abbot poses a threat; therefore, the Ten Tigers will take Black Flag troops on “manoeuvres” near the villages controlled by the Abbot’s army while the Doctor deals directly with Qin. He must get to Xi’an before the conjunction, and Vicki suggests tapping into the possessed monks’ ability to travel instantaneously across great distances. The Doctor hypnotises Yeung again, finds that the formerly possessed monk still retains this ability, and takes advantage of it to transport himself and his friends to Xi’an.
The Doctor now has enough information to deduce what Qin has been doing. The British and the Tigers have been unable to determine the logic behind his attacks because he’s been seizing, not political targets, but sacred sites where the alien energy will be absorbed into the land itself by the “stone tape” effect. The ghost sightings have been caused by some of the alien energy leaking out of the system; when the full alien power floods through the network Qin has created, it will be as if the whole of China has become a formatted disc running an alien programme.
Ian points out that the servants who constructed the Emperor’s tomb must have needed fresh water, and that the water table must be buried but accessible; if they can find it, they can flood the complex and perhaps short out the alien energy. But before the Doctor’s allies can start, a beam of alien energy roars out of the sky and into the mountain, and the Doctor realises that he’s forgotten to take the changeover from the Julian to the Gregorian calendars into account in his calculations. The conjunction has come earlier than expected, catching them all unprepared.
The Doctor enters the tomb to distract Qin while Major Chesterton and his men set to work. The alien plasma is pouring into the cavern of jewels and mercury where the monks were possessed, a helix of energy waiting to be beamed out across the whole of China. The energy brings the Eight Thousand terracotta warriors to life, and as the soldiers fight off their attackers, Logan and Fei-Hung track down the hidden water table, plant explosives and blow open the barrier, flooding the tombs with water. The British soldiers’ guns and swords have no effect on the terracotta statues until Ian finds an abandoned sledgehammer, left over from the tomb’s construction, and uses it to smash one of the attackers into shards. The British soldiers thus turn their rifle butts on their enemies. In the course of the fighting, Vicki notices Logan’s reaction when Major Chesterton’s life is threatened, and realises what Logan’s true feelings for the Major must be.
The Doctor confronts Qin in the Emperor’s old burial chamber, which is being reconstructed from the ruins by the alien plasma. The Doctor dismisses Qin as a mere copy of a dead man’s memories, and as Qin protests, the alien force disposes of him and speaks directly to the Doctor through the Abbot’s mouth. Though the Doctor isn’t aware of it, he has defeated the helix once before, nearly 400 years ago; now, it will make him and Barbara its puppets. But as the Abbot and Gao try to force the Doctor and Barbara into the stream of alien plasma, water floods into the tomb and Ian and Fei-Hung arrive to defend their friends. As the chamber floods with water, the Emperor Qin’s mind regains some control of the Abbot’s body -- and, realising that he’s been used as a pawn by a force which intends to conquer his beloved empire, Qin deliberately steps into the water, shorting out the alien plasma within the tomb.
Outside, the British soldiers emerge from the tomb to find themselves facing an entire army of the terracotta warriors, who have been attacking Qin’s human followers, possibly for practice. Before the warriors can attack the British, however, Qin shorts out the plasma stream, and the terracotta army collapses. Inside the tomb, Abbot Wu recovers, with no memory of anything that happened to him after his battle with the bandits. The alien evil defeated, the Doctor and his friends return to Guangzhou. On the way, Barbara asks Ian to marry her, and he accepts; they will wed once they return to London. The Doctor and his friends remain in Guangzhou for the wedding of Fei-Hung and Miss Law, and then depart in the TARDIS for adventures elsewhere.