The Doctor and Leela arrive in London so that Leela can learn about the customs of her ancestors, specifically the musical theatre of Victorian England. Performing at the Palace Theatre on an extended run is the stage magician Li H'sen Chang, although the Doctor did hope to catch Little Tich. On their way to the Palace Theatre, the Doctor and Leela encounter a group of Chinese men who have apparently killed a cab driver. They attempt to silence the Doctor and Leela but are frightened away by the distant whistle of an approaching peeler. All but one escape, and he, the Doctor and Leela are taken to the local police station.
At the station, Li H'sen Chang is called in to act as an interpreter, but unbeknownst to everyone else he is the leader of the group and he secretly gives the captive henchman a pill of concentrated scorpion venom, which the henchman takes immediately and dies. The Doctor, upon a brief examination of the body finds a scorpion tattoo – the symbol of the Tong of the Black Scorpion, devout followers of an ancient god Weng-Chiang.
The body is taken to the local mortuary, along with the body of the cabbie which had just been found floating in the river. There they meet Professor Litefoot, who is performing the autopsies. The cabbie is Joseph Buller, who had been looking for his wife Emma, the latest in a string of missing women in the area. Buller had gone down to the Palace Theatre where he had confronted Chang about his wife's disappearance, threatening to report Chang to the police if she was not returned to him. Chang, fearful of discovery, had sent his men, including the diminutive Mr Sin, to kill Buller. Chang is in the service of Magnus Greel, a despot from the 51st century who had fled from the authorities in a time cabinet. The technology of the cabinet is based on "zygma energy," which is unstable and has disrupted Greel's own DNA. deforming him horribly. This forces him to drain the life essences from young women to keep himself alive. At the same time, Greel is in search of his cabinet, taken from him by Chinese Imperial soldiers, and which in turn had been given by the Imperial Court to Professor Litefoot's parents as a gift. Mr Sin is also from the future but is a robotic toy constructed with the cerebral cortex of a pig. It is better known as the Peking Homunculus, a vile thing that almost caused World War Six when its organic pig part took over the toy's functions.
Greel tracks down the time cabinet and steals it, whilst concurrently the Doctor tracks Greel to the sewers underneath the Palace Theatre, aided (rather clumsily) by the theatre's owner, Henry Gordon Jago. However, Greel has already fled his lair, abandoning Chang to the police. Chang escapes but only to be mauled by one of the giant rats – products of Greel's experiments, which were then used to guard his sewer hideout.
While the Doctor and Leela try to find Greel's new hideout, Jago comes across a bag of future technological artefacts, among which is the key to the time cabinet. He takes it to Professor Litefoot's house, and there, after leaving the artefacts and a note for the Doctor, the Professor and Jago set out to follow anyone coming around the Palace Theatre in search of the bag. However, they are captured for their efforts. Meanwhile, the Doctor and Leela happen upon Chang in an opium den, already half dead from his injuries and the narcotic; there, he tells them that Greel can be found in the House of the Dragon but falls into rambling and dies before telling them its exact location. He does leave them a Chinese that tells the Doctor that Greel's lair is in a Boot Court somewhere.
The Doctor and Leela return to Professor Litefoot's house. There they find the note and the key to the time cabinet. They decide to wait for Greel and his henchmen. When they arrive, the Doctor uses the key, a fragile crystal known as a Trionic Lattice, as a bargaining chip. He asks to be taken to the House of the Dragon, offering the key in exchange for Lightfoot and Jago's release. Instead, Greel overpowers the Doctor and locks him in with the two amateur sleuths.
Leela, who had been left at Litefoot's house at the Doctor's behest, has followed them and confronts Greel. She is captured and set in his life-essence extraction machine, a catalytic extraction chamber, but before her life essence is drained in order to feed Greel, the Doctor, Jago and Litefoot escape and rescue her. In a final confrontation, Mr Sin turns on Greel as the Doctor convinces it that Greel escaping in his time cabinet will create a catastrophic implosion. The Doctor defeats Greel by forcibly pushing him into his own catalytic extraction chamber, thus damaging it and causing it to overload. Having fallen victim to his own machine, Greel suffers Cellular Collapse and disintegrates. Enraged by the events, the Peking Homunculus attacks Leela, but the Doctor manages to remove its prime fuse and damage it beyond repair before bringing the Zygma Experiment to a permanent end by destroying the lattice, just in time for the coming dawn and the muffin man.
As the Doctor prepares the TARDIS, Litefoot attempts to explain tea to Leela, only to baffle her further. The Doctor and Leela bid farewell to Jago and Litefoot as they enter the TARDIS. Confused by the police box, Litefoot is astonished by its de-materialisation, a stunt which Jago remarks that even Li H'sen Chang could have appreciated.