The Doctor is taking Sam to the debut of the opera Aida when an anomaly in hyperspace draws the TARDIS off course. It materializes on the planet Janus Prime, a night world of luminous blue sands, where the Doctor and Sam are just in time to save the fleeing Julya from a cybernetically enhanced “spidroid”. Pursued by soldiers in spacesuits, the Doctor and Sam try to accompany Julya to the “Link”, but Sam is shot while crossing open ground and is captured. The Doctor, Julya and Julya’s suspicious partner Lunder escape through the Link, which appears to be a transmat beam connecting Janus Prime to its twin world, Menda. Kleiner, the spokesman for Menda’s government, refuses to let the Doctor return to Janus Prime, as they need his knowledge to help deal with their enemies. The Doctor learns to his horror that Janus Prime is lethally radioactive, and Sam is now stranded there...
Menda and Janus Prime are twin worlds on either side of a red giant sun, but while Menda is bright and fertile, Janus is dead and shrouded by a perpetual solar eclipse. A colony ship from Earth crashed on Menda some years ago, and the mercenaries whom the colonists had hired to protect them on the journey were thus stranded with them. What the colonists had not realized was that these mercenaries were former soldiers who had been dishonourably discharged after a firefight with Cybermen resulted in the deaths of all of the Cybermen’s human hostages. When they discovered the Link, apparently the remains of an ancient civilisation, the soldiers’ leader, Gustav Zemler, took his men through to Janus Prime, itching for action and hoping to find a way back to Earth. But the Link turned out to connect only the two planets, and exposure to the radiation of Janus Prime caused the soldiers’ bodies to begin dissolving. The rate of decay only increases if they depart from the planet; they are thus doomed to remain on Janus Prime and die slowly. Furious, and blaming the colonists for their predicament, Zemler and his men declared war, cybernetically enhanced the giant spiders native to Janus Prime and sent them through the Link to battle the colonists. The war has been stalemated for some time, and Julya, Lunder and Vigo were sent through the Link to find out if Zemler had any new plans. But Vigo was captured, and Julya and Lunder were forced to retreat.
The Doctor studies the body of a Janusian spider and discovers that the area of the brain used to produce alpha waves has atrophied; significantly, the ancient machinery around the Link is controlled by alpha waves on a specific frequency. The Doctor is determined to return to Janus Prime, rescue Sam and learn more, and Julya, having come to trust him, volunteers to accompany him. Lunder also accompanies them, determined to rescue Vigo. Meanwhile, Sam and Vigo are brought to Zemler, and when Vigo attacks him, Zemler shoots him. Vigo’s body dissolves into froth, and Sam passes out, only to awaken aboard a shuttle. A sympathetic soldier claims to be taking her back to the Link to get away from the mad Zemler, but in fact Sergeant Moslei has studied the data downloaded from the attacking spidroids and have seen the materialization of the TARDIS. Sam has been implanted with a tracer, and unwittingly leads the soldiers straight to the TARDIS.
The Doctor takes Julya to the TARDIS while Lunder holds off the attacking spidroids. Once there the Doctor discovers that Janus Prime’s moon has a mass equivalent to that of a sun, most of which is hidden in hyperspace. If Menda’s moon is the same, this explains the distortion that brought the TARDIS here. The Link is not deliberate, but a side-effect of an ancient device of incalculable power -- which is going wrong. The Doctor and Julya emerge from the TARDIS only to be captured by the soldiers who have followed Sam. Lunder opens fire from hiding, and although Sam uses the distraction to escape, the Doctor remains to lock the TARDIS door and he and Julya are captured. Lunder blames Sam and pursues her, but can’t bring himself to kill her in cold blood. She tells him what happened to Vigo, and Lunder grows to respect her when, realizing the soldiers implanted a tracer in her, she uses Lunder’s knife to dig it out of the wound in her shoulder despite the pain this causes her. She accompanies Lunder to Zemler’s base, where he gives her a gun and tells her to cause a distraction while he rescues Julya and the Doctor.
Zemler is nearly in control of the ancient machinery on Janus Prime, but he is also completely insane; the planet’s radiation destroys the lipids which hold together the cells of the human body, and Zemler’s brain is literally melting inside his skull. The Doctor and Julya are thrown to the spider Queen, but the Doctor manages to establish a mental rapport with the newly hatched spiderlings and shares their race memory. Outside, Sam opens fire on the empty parts of the base to distract the guards, but unwittingly sets the spider enclosure on fire as well, killing a number of spiderlings and enraging the Queen. Lunder, much to the Doctor’s anger, shoots the spider Queen while rescuing him and Julya. The Doctor insists that they destroy the spidroid control centre before leaving, freeing the Janusians from Zemler’s control. Zemler, knowing that the Doctor could spoil everything, sends Moslei to stop him; Zemler has learned all he needs to know and is ready to establish the conjunction.
Back on Menda, Sam goes to the medical bay, but learns that it’s too late; she has been exposed to the radiation for too long and her skin is melting. The Mendan government believes that Zemler will soon be dead and that the problem will resolve itself, but the Doctor attempts to warn them that the situation is more critical than ever. Life developed on both Janus Prime and Menda long ago, and the two species found themselves at war and decided to develop the ultimate deterrent -- the impossibly massive moons, which if moved into conjunction could turn the sun supernova. The deterrent did not deter the final war, however, in which Janus Prime’s moon was moved into its permanent geostationary orbit, the Mendans were completely wiped out, and Janus Prime was seeded with isotope decay bombs which irradiated the planet and caused the natives’ deterioration into savages. Newly hatched spiderlings still retain the facility to generate alpha waves, which they lose as they mature, and Zemler can use them to operate Janus Prime’s side of the Link and move Menda’s moon into conjunction. But over the millenia since the weapon was made, the star has become a red giant, and that has destabilised the balance between the moons. Thus the Link has been created and the Conjunction, if established now, will turn Janus into a black hole and damage this entire part of the galaxy.
When the government refuses to listen to him the Doctor sets off to deal with Zemler himself. Julya, Lunder and Kleiner follow him to the Link, only to find that Moslei and his men have arrived, protected from further deterioration by their spacesuits, and seized control. Moslei is having doubts but carries out his orders regardless, killing Kleiner when the Doctor refuses to help ensure that the Mendan machinery can’t be used. In any case it’s too late; the machinery has atrophied through lack of use and all it can do now, if necessary, is crash Janus Prime’s moon into the planet. Before resorting to such extremes, the Doctor convinces Julya and the dying Sam to distract the guards while he goes to Janus Prime and tries to talk sense into Zemler. He fails; Zemler has begun the conjunction and killed all the spiderlings to ensure that nobody else can operate the Link.
As Menda goes into eclipse the government realizes, too late, that the Doctor was telling the truth all along. Faced with the fact of Menda’s destruction, Moslei finally acknowledges the madness of his actions and accompanies Lunder back to Janus Prime to rescue the Doctor while Julya crashes Janus Prime’s moon into the planet. When they arrive on Janus Prime Moslei shoots and kills Zemler, but the Doctor reveals that by moving the moon, Julya has destabilised the Link and it no longer connects the two planets. Menda is safe, but Janus Prime is doomed and the Doctor, Lunder and Moslei are trapped. The Doctor tries to walk into the Link, claiming that if it is destabilised the moon will return to its original position, but Moslei leaps in first, sacrificing himself and stabilising the moon. The Doctor takes Lunder back to the TARDIS, which he pilots into a temporal orbit so he can spend as long as necessary finding a cure for Sam and still get it to her in time. He also cures Zemler’s surviving soldiers, who must accept a new life as farmers and colonists. The Doctor and the recovering Sam depart, leaving the people of Menda with new hope for the future.