The TARDIS is drawn into the distant future with the Doctor, Donna, and Martha trapped inside. The Doctor's severed hand is reacting, suggesting that some version of the Doctor is nearby. The ship finally materializes on its own and they emerge to find themselves in an underground tunnel. A group of human soldiers take them prisoner, determine they're "clean," and then force the Doctor's hand into a nearby machine. It extracts a skin sample and then processes it. A nearby chamber opens and a blonde girl in military uniform emerges. The Doctor realizes that the machine has used his skin sample to create a genetic clone/spinoff: his "daughter."
The girl, Jenny, has already had military tactics downloaded into her mind during the creation process. She joins the other human soldiers, and a group of alien soldiers, the Hath, attack them. Several of the human soldiers are gunned down and one of the Hath grabs Martha and drags her back up the tunnel. Jenny grabs a remote detonator and sets off explosives in the tunnel, sealing off the way to Martha and the TARDIS. The Doctor tries to rescue his companion, but the remaining soldiers and Donna take he and Donna to their commander, General Cobb.
Martha wakes up on the other side of the cave-in and tends to an injured Hath soldier. He reluctantly accepts her help. His comrades arrive and take both of them back to their base.
General Cobb meets with the Doctor and Donna, and assumes they're from an outlying sector due to their ignorance of the situation. He explains they're on the planet Messaline and the humans are battling the Hath so that they can acquire the Source, a religious artifact that represents the Breath of their Creator. The humans and Hath were brought to the planet together to colonize it, but the Hath turned against the humans and set off a war. Both sides now use the progenation machines to generate troops and replace their fallen comrades.
The Doctor accesses a holographic map of the city, unaware that Martha is doing the same in the Hath base. He finds the lost temple holding the Source, unaware that the same readout is appearing to Martha and the Hath. Cobb orders his men to get it and ignores the doctor's suggestion of peace. He suspects the Doctor of pacifism and orders him and Donna locked up. He has Jenny locked up with them, believing she has similar pacifism genes as the Doctor and could pose a risk to the mission. Meanwhile, the Hath launch an expedition to the temple, leaving Martha and the Hath she has befriended behind.
As they're taken to a cell, Donna notices a series of 8-digit numbered plaques. The Doctor figures the Source is some kind of weapon or power source and plans their escape, and Jenny notes that he's acting like a general despite the fact he claims he isn't a soldier. The Doctor dismisses her concerns and her attempts to befriend him, but she looks forward to learning from his experience. He then calls Martha on her cell phone and she tells him the Hath are heading for the temple, but her battery goes dead, cutting her off. Ready to leave, the Doctor tells Jenny to stay behind, as he's concerned her soldier instincts will force her to attack the Hath. Donna uses a stethoscope to demonstrate that Jenny has two hearts, just like the Doctor, but he insists that being a Time Lord is more than just physical similarity. There's the shared experience of being a family, and he notes that he is the only survivor of the Time War. When he admits that he fought and killed as a soldier, Jenny wonders if they're different at all.
Martha and her Hat bring up a full display of the map in 3-D and discover a surface route to the temple where it extends above the surface of Messaline. Martha insists on taking the route and the Hath reluctantly follows.
Jenny seduces the guard and lures him in so that she can grab him and force him to give them the key. Once they're out, the Doctor tries to slip by a guard without violence, but Jenny attacks the soldier and knocks him out, against the Doctor's wishes.
As Martha and her Hath get to a surface hatch and go outside, Cobb learns of the Doctor's escape and orders his men forward, insisting no one will stop him from acquiring the Source.
As they run through the tunnels to the Source, Donna spots more of the numbered plaques and realizes that they're in descending order. She then explains to an impressed Jenny what the Doctor does with his life. They come to a laser grid and the Doctor tries to deactivate it, while Cobb and his men close in. Jenny prepares to shoot them but the Doctor insists that violence isn't the solution. She goes to buy them time but hesitates and then shoots a gas pipe, creating a smoke screen to block Cobb and the others. The Doctor temporarily shuts down the grid and gets through with Donna, but it comes back up before Jenny can get through. She acrobatically ducks and weaves through the grid, thanks to the heightened reflexes she's gained from the Doctor's genes, and even he's impressed. As they leave, the Doctor calls back to Cobb warning that if the Source is a weapon, he'll destroy it rather then let it fall into anyone else's hands.
As Martha travels across the surface, she falls into a pit of quicksand. Her Hath friend tries to pull her out and is forced to jump into the quicksand and then lift her free. However, he's sucked down to his death.
As they run through the tunnels, Donna stutters her way through an explanation of how she and the Doctor are involved. She suggests that Jenny travel with them and the Doctor agrees. However, as she runs ahead to scout, the Doctor admits to Donna that he has been a father in the past, and Jenny's presence is painful because it reminds him of the children that he's lost.
They reach the temple from the tunnels, while Martha gains entrance from the surface. The Doctor seals the door behind them and realizes that the temple is actually a space ship with a working fusion drives. Checking the ship's log, he discovers that the mission commander died shortly upon arrival and the two sides, Hath and human, split up over the power vacuum. Donna finds another numbered plaque and realizes they represent dates transcribed in an American format. Each plaque shows the completion date of sections as robots assembles each region, in a progression extending outward from the "temple." However, they discover that the dates indicate that only seven days have passed since the spaceship landed. Since the machines have recreated and replaced all of the humans and Hath alike, none of them know their own origins or how recently the original colonists arrived.
Reunited, the Doctor, Donna, and Martha find an enormous greenhouse containing the Source: a terraforming sphere in low-power mode. The Hath and the humans both gain access and the Doctor tells them that their religious artifact is merely a bubble of gasses designed to accelerate evolution. He offers them a future, and then shatters the Source on the ground. As the area around them starts to terraform, the Doctor says that he is ending the war. The two sides put down their guns. However, Cobb, obsessed, tries to shoot the Doctor. Jenny leaps in the way and takes the bullet meant for her "father." She lies dying and the Doctor tries to reassure her. She dies, but Martha warns that she isn't enough like the Doctor or a Time Lord to regenerate. The Doctor, furious, grabs a gun and confronts Cobb, but says that violence is never the way. He tells both sides to turn to peace rather than war, and then sits by his "daughter" side.
As the terraforming process continues, the Hath and the humans prepare to give Jenny a proper burial. The Doctor and his companions leave, and he explains that the TARDIS homed in on Jenny and arrived just prior to the point in time where she was created. He takes them back to Earth where Martha has decided to stay and look after her family, and get married. Donna says that she could never go back to an ordinary life, and will stay with the Doctor always. The two of them leave while Martha considers her engagement ring and then goes into her flat.
As they prepare to bury Jenny, the humans and Hath look on in wonder as a glowing gas emerges from her mouth. She looks up at them, smiles… then runs off to find a shuttle. She leaves Messalene, saying that now she has a whole universe to explore, evil to fight… and a whole lot of running to do.