A Vortex discontinuity causes the TARDIS to materialize in the year 3123, near a probability nexus centred on a four-kilometre-long alien ship with a partial extrusion into hyperspace. The derelict has been claimed by both an Emindian passenger liner, the Cirrandaria, and a Nimosian battle cruiser, the Indomitable. The Doctor, fearing the consequences should either of the two rival powers access the unknown powers of the derelict, materializes aboard the Cirrandaria with forged documents identifying him and Sam as Federation Moderators. As such, they join an expedition to the derelict led by prominent Emindian politician J. Kale Rexton -- who seems to know more about the derelict than he’s saying. Rexton also allows celebrity photographer Lyset Wynter to document the expedition, and, more reluctantly, allows her actor fiance Don Delray to accompany her. Fifty years ago, Rexton was found alone in the streets of Emindar at seven years of age with no memory of who he was, and yet he has risen to the most prominent political position on the planet; he loves his world, and will do anything it takes to ensure its political superiority.
The Doctor soon deduces that the derelict is an experimental hyperspatial bridge, and Rexton eventually admits that Emindian scientists found a similar, damaged ship some years ago, and have been studying it in a deep space research facility. Rexton leads the expedition through a temporal laboratory where Sam is accidentally reversed through Time, becoming ten years old. The Doctor is able to correct the situation and notices that the temporal potential was balanced with the use of organic panels which aged and de-aged at the same rate as Sam. Much to Rexton’s surprise, the derelict’s controls have been labelled with index cards with clearly-written English translations; however, half of the control room is on the other side of the hyperspatial interface and is thus inaccessible. He orders Wynter to photograph the controls; the Emindian scientists studying the original ship can use this information to repair it.
A Nimosian boarding party lands on the derelict only to be attacked by forces unknown. When the Emindian expedition’s pilot enters the derelict to warn the others, he is captured by a hideous wraith and dragged through the interface. Further monstrosities emerge and attack the others, and Wynter is captured and dragged through the interface -- although Rexton manages to grab the camera with the vital photographs. The ghosts seem to drain the life energy out of their victims, but the Doctor is able to drive them off with pulses from his sonic screwdriver. The survivors of the expedition return to the Cirrandaria, where the Doctor theorizes that the “monsters” are in fact the crew of the alien ship, time-shifted out of phase by a side effect of their dangerously experimental space-warping technology, and desperate to bring themselves back into phase.
Wraiths and ghosts begin to appear on both the Cirrandaria and the Indomitable, haunting the passengers and crew and spreading confusion and panic. The Doctor builds a “normaliser” which can temporarly rephase and dephase the attackers, thus driving them away -- but an army of the monstrosities attacks the Cirrandaria, kidnapping several passengers and crew, dephasing them and dragging them through the interface. Sam is also kidnapped, but her kidnappers appear more humanoid than the others. The Doctor drives off the attackers by blanketing the Cirrandaria with a “normalisation” pulse, and then demands that the Nimosians be allowed to accompany the rescue mission. Commodore Vega of the Indomitable decides to accompany the expedition in person to find out what’s really going on. Rexton reluctantly agrees to allow the Nimosians to participate -- although his own first priority is not to rescue the kidnapped passengers, but to get photographs of the labels on the other side of the interface. Delray also accompanies them, but he has his own agenda, related to a personal ghost which has been haunting him since Wynter’s loss...
The Doctor loads the TARDIS on board the Emindian shuttle, and both they and the Nimosians pass through the hyperspace bridge -- and emerge in a starport above the ruins of what was once the planet Emindar. The other side of the ship is located 20 years in the future, after both Emindar and Nimos have been destroyed by war. The ghosts of the Cirrandaria’s Captain Lanchard and of Commodore Vega appear to the expedition team and show them the ghost of the Cirrandaria itself, located on the other side of the spaceport. None of the wraiths can remember what caused them to become like this, but they know it happened during the first battle of the war, which was fought over the alien derelict. After the accident, most of the Cirrandaria’s passengers went insane, and in their dephased state they degenerated into monstrosities. Those who managed to keep control piloted the ship back to Emindar, only to arrive after the planet was already dead. They found this ship in the ruins of the spaceport, and tried to use the clearly labelled controls to go back in time to stop the incident from occurring. Rexton is horrified by these revelations and returns to the alien ship, determined to complete his mission, change the future and save his planet.
The Doctor realizes that the derelict is the centre of a time loop; there is only one ship, not two. Rexton’s photographs of the labels will be sent to the scientists studying the “first” ship, who will use them to label the controls and repair the ship. The ship will be brought back to Emindar during the war, and the wraiths will use it to go back in time -- where it will be located by the Cirrandaria and the Indomitable. Even as they speak, Emindian and Nimosian reinforcements are arriving at the other side of the bridge and tensions between the fleets are growing. Following a domestic tragedy which was exacerbated by the appearance of the ghosts, a passenger on the Cirrandaria tries to flee in a lifeboat, but nearly collides with a Nimosian cruiser, which is forced to shoot it down. This only worsens matters. Soon the first battle of the war will begin, the accident which dephased the Cirrandaria will occur, and there is nothing the Doctor can do to stop it.
Wynter, meanwhile, has been abandoned by the insane monstrosities only to be captured by a shell-shocked Nimosian marine, Sho, who is convinced that everything he’s encountered has been part of a complex Emindian plot. Sho finds a group of wraiths who turn out to be confused Nimosian soldiers; they gratefully follow Sho’s orders and attack the enemy, although none of them are sure who the enemy is. As the Nimosian ghosts attack the ghost-Cirrandaria, Sho holds Wynter as a hostage, convinced that the Nimosians on the rescue mission are all traitors. Delray rescues her, and is shot by Sho while saving Wynter’s life. The Nimosian attack succeeds -- and the hordes of insane monstrosities aboard the ghost-Cirrandaria are released. Sho is consumed by the monstrosities, but the ghosts of Vega and Lanchard hold off the monstrosities while the others -- including Sam and the other kidnapped passengers -- reach safety in the TARDIS. There, Delray dies, but his own wraith appears and explains that in the past history he experienced, his cowardice resulted in Wynter’s death. The wraith vanishes, and the Doctor realizes that it may be possible to make changes within the time loop after all.
The Doctor returns Vega and the others to the Cirrandaria, and Lanchard and Vega try to convince their respective fleets to back down. They fail, and the first battle of the war begins. Resigned to their fate, Lanchard and Vega urge the Doctor and Sam to escape. The insane have now seized control of the ghost-Cirrandaria and are piloting it across the bridge in a desperate attempt to steal back their lives from their former selves. The Doctor realizes that the two Cirrandarias will attempt to occupy the same position in time and space, resulting in a catastrophic release of temporal energy which will dephase the original Cirrandaria... thus creating the ghosts in the first place. He can disperse the ghosts by releasing an energy pulse from the TARDIS, but decides to follow Delray’s example and release the pulse a fraction of a second earlier, hoping to stop the ghosts from ever having existed.
Rexton is trapped on the derelict during the fighting and tries to pilot it to safety out of the war zone, but it collides with a burning battle cruiser. As he tries to flee he stumbles into the temporal laboratory, where he is reversed to seven years of age and falls into the hyperspace tunnel -- colliding with the ghost-Cirrandaria and the original just as they Time Ram and the Doctor fires an energy pulse from the TARDIS. As a result of the Doctor’s actions, a dephased duplicate of the Cirrandaria is brought into existence while the “original” ghosts are dispersed. Thus the Doctor saves the “real” ship; the ghosts they encountered were only duplicates, and the Doctor has dispersed them. Thanks to Rexton’s attempt to pilot the ship to safety, the kickback knocks the real Cirrandaria a thousand years into the future, while the damaged derelict travels back in time a few years, to be found by the Emindians and taken to a deep space research facility.
The Emindians and Nimosians aboard the Cirrandaria, shaken by their experiences, make peace and prepare to start a new life in a sector which has been abandoned since the devastating war. As the Doctor and Sam go, the Doctor refers to the dephased crew of the ghost-ship as “Vanderdeken’s children”, the metaphorical descendents of the legendary Flying Dutchman, doomed to travel without end. They’re not the only ones; the de-aged Rexton has been kicked backwards fifty years in time to balance the slight forward motion of the more massive ghost-ship. He is found alone in the streets of Emindar at seven years of age, with no memory of who he is...