The intelligent inhabitants of Bellania II are degenerating into savagery as their world becomes too cold to support life. One day, however, their sun is surrounded by three moonlike objects and goes out, to be returned a year later, younger, hotter, and brighter. Now the people of Bellania II, those few who have survived, find their world growing too hot to support life... Ten million years later, Eldred Saketh, a follower of a cult which worships death as the perfect Endless State, arrives on the toxic, burning surface of Bellania II to die. But instead, he begins to change -- as the sun itself also begins to change...
The TARDIS is affected by waves of gravitational turbulence which expel theDoctor and Sam into a colony on the moon of Bellania VI. The moon is being torn apart by tectonic disturbances caused by the star Belís gravitational fluctuations, and the colony is breaking apart. Sam is swept up amongst panic-stricken crowds as the colony begins to depressurize, but is saved by Father Denadi, a priest of the death-cult. He takes her to a gathering of his followers, who are preparing to commit mass suicide, but then Saketh arrives -- dead yet living, Endless in life; immortal. He steps through an airlock onto the airless surface of the moon, yet does not die, and the frightened cultists accept his new word and take communion with him, also becoming living Endless. Only Sam and Denadi reject his offer.
The Doctor, meanwhile, ends up aboard a medical frigate which is bombarded by asteroids as the moon breaks up. The Doctor successfully repairs the shipís asteroid defense systems, but it crashes on Bellania VI before he realizes that its engines have also been damaged. As chunks of the former moon begin to crash into the planet, tsunami sweep across its oceans, but the Doctor is able to whip together a gravity generator from bits of the ship and its engines. When the tsunamis reach the crash site he and the refugees from the ship are able to use the generator to surf the wave to the continental coast, and then stop it before it destroys the planetís capital city.
Other refugees from the disaster have been taken to Bellania VIII, which is unable to support the sudden inrush. Panic and confusion spread through the refugee centres as more and more new arrivals crowd in, and Sam, caught up in a riot, is unable to save a young boy from being crushed nearly to death. Desperate to save his life, she gives permission for Saketh to make him Endless, although later when he is reunited with his parents they are furious with Sam for doing this. Sam is then reunited with the Doctor, who addresses a meeting of the systemís government, telling them that the sunís fluctuations are bound to get worse. He can show them how to build more gravity generators for use as stopgap measures; if placed in orbit around the inhabited planets they can cancel out the gravity waves from the sun and save the inhabitants. Until the sun goes nova, that is. But in the meantime the Doctor intends to investigate and find a permanent solution.
Rather than help the Doctor, Sam decides to remain with the refugees and do what she can to save lives -- and to work through the difficult questions raised by Denadi and Sakethís beliefs. She accompanies a rescue team to a radiation-swept moon and works through the night and the day, taking drugs to stay awake and help. Eventually she finds a radiation-permeated man and his newborn son whom she is unable to save, and begs Saketh to do it for her; but he refuses to do so unless they give permission. Sam can only save them if she agrees of her own free will to take Sakethís communion, and then save their lives herself.
Sleep-deprived and overdosed on stimulants, Sam wanders away to think -- and at that moment an empathic message is felt by every inhabitant of the Bel system, sent from some other intelligent life form trying to communicate. Sam interprets it as a message, a memory from her future -- a memory of her accidentally killing a young girl in a car crash, and of the girlís father refusing permission for the operation which would save her life, due to his religious principles. Sam stumbles to the bridge and urges the crew to crash into the nearby ice moon, and Saketh supports her decision. The ship plunges through the ice into the ocean beneath just as another gravity fluctuation from Bel causes a radiation surge which irradiates the rest of the medical fleet, dooming its occupants to a slow, painful death.
The Doctor goes with medical officer Conaway to a moon of Bellania XXI, where for centuries the people of the system have been dumping biological and chemical weapons. A recent initiative to experiment in terraforming procedures led to the accumulated weapons-waste being dumped into the sun, and the Doctor hopes to find a connection. Instead he and Conaway are arrested by Major-General Smoot for trespassing on a military site, and by the time they convince Smoot that they are working on behalf of Belís governments, events have moved on. Three new planetary bodies have entered the system, and an empathic message has been received by almost every inhabitant of the system. The message has been interpreted in many ways but it seems the people of the system must die so others may live...
Smoot is sent to intercept the new planets and prevent anyone from making contact with them, but a civilian fleet arrives in the area, convinced that the planets hold their salvation. Due to misunderstandings a battle breaks out and over a hundred civilian ships are destroyed. Conaway crashes on one of the new planets while trying to rescue the wounded from the battle, and Smoot, appalled by the carnage he has caused, reluctantly authorises a rescue mission. The Doctor accompanies officer Aellini to the new planet, where he finds Conaway wrapped up amongst the vegetation -- but as he tries to free her he experiences a vision, as if it is he who is giving birth and placing his child in an incubator. And the incubator is a dying red giant star, Bel as it once was. He and Conaway awaken to realize that they have tapped into the planetís memories; it is in reality one of a tripartite life form in the process of giving birth, a process which is now taking place prematurely because of the biochemical weaponry dumped into Bel. And even if the birth of the alien entity is successful, it will cause Bel to go nova, wiping out all life in the system.
Saketh travels to the airless surface of the ice moon to spread Communion amongst the refugees irradiated by the recent surge. Sam, having had further visions, goes to him as well to take Communion, literally eating of his flesh and blood to become immortal. But on this moon, Endlessness means endless pain, as the skin and body perpetually heals from the agony of radiation burns, decompression and freezing. Sam gives the dying Denadi Communion against his wishes, and he follows her when she swims through the frozen sea back to the refugee ship, which she repairs. Denadi realizes that Sam has gone mad from the pain and stress; she apparently believes that the empathic message came from the Hoth, the creatures which live in the gas giant of Bel. Sam pilots the ship into the gas giantís gravity well and collides with a Hoth, and the pressure destroys the ship, thus expelling Sam and Denadi into the body of the Hoth -- which also becomes Endless, and takes them to Bellania VIII to spread the word.
Aellini reports the Doctor and Conawayís discovery to Smoot, who in turn reports to his superiors -- and is ordered to take the Doctorís gravity generators out of orbit and use them as weapons against the new arrivals. The Doctor is unable to convince Smoot to mutiny, although Smoot is fully aware that the generators provide the inhabited worldsí only protection from Belís fluctuations -- and that even the stillbirth of the alien entity will result in a supernova that will destroy all life in any case. As news of Smootís decision spreads throughout the fleet, a new civil war breaks out. As the Doctor blames himself for the disastrous situation, Saketh arrives to tell the Doctor about Samís presence on Bellania VIII. Since Saketh no longer requires air to survive he can cross to the generators unaided and reprogramme them, preventing Smootís plan while the Doctor goes to Bellania VIII to find out whatís happening to Sam.
The population of Bellania VIII has tripled overnight due to the influx of refugees, but by the time the Doctor arrives more than three-quarters of them have been converted to Endlessness. The Doctor speaks with Sam and realizes that she, like all the other Endless, is being kept alive by nanotechnological machines from Bellania II. The society there was once technologically advanced before devolving into primitivism and dying out, but their machines survived and evolved, becoming a life form in their own right. They were trapped on Bellania II until Saketh arrived; now, they are keeping their humanoid hosts alive as incubators in which to procreate. But to reach its next stage of evolution the nanotech requires more energy -- and the Doctor realizes that Saketh intends to use the generators to destabilise the star, provoking the alien entityís birth and a nova which will kill everyone in the Bel system. Sam, however, points out the flaw in his argument; why would the nanotech wish to kill their gods? They will use the power to evolve but will save the lives of their hosts, and will then use the gravity generators to restore Bel to the state it was in before the world-aliens arrived -- dying, but with enough life to it for the people of the Bel system to survive for millenia more.
The Doctor stands by and waits as all goes according to the nanotechís plan. The star gives birth to the fourth of the world-beings, and although many who did not accept Endlessness are killed, the rest survive and the nanotech evolves to a new form. Sam is restored to herself, and she and the Doctor return to the TARDIS, which is floating indestructibly amongst the remains of Bellania VIís moon. They depart, leaving the people of the Bel system with the hope of a new life, as the world-beings also depart with no idea of what their intervention has meant to the other life forms involved.