The TARDIS is flying on its own as the Doctor tries to take control without success. It finally materializes and they merge to find themselves underground in a chamber filled with rubbish. Soldiers come in and take the Doctor, prisoner and put his hand into a machine for "processing." He realizes it's taking a tissue sample and is some kind of accelerated processor. As they look on, a nearby chamber opens and a blonde woman girl emerges. The Doctor realizes that the girl is… h is daughter.
The girl has had military tactics downloaded into her mind to participate on the ongoing war. The Doctor explains that the machine grew her from his cells. They're interrupted when another group of masked alien soldiers attack. The human soldiers are gunned down and one of the aliens grabs Martha. The girl grabs a remote and blows the tunnels, sealing off the aliens on the other side…. along with the TARDIS The Doctor tries to go after Martha, but the soldiers take him and Donna to General Cobb, their commander.
Martha wakes up and tends to a wounded alien, who she refuses to abandon even when his comrades arrive. They take her and the wounded soldier with them.
The Doctor and Donna meet with Cobb and bluff the fact that they're from an outlying sector. It's explained they're on the planet Messaline and the humans are at war with the Hath.
Martha is brought to a chamber where the Hath touch her curiously. Meanwhile, Cobb explains that it was intended the humans and Hath were supposed to live together in a colony, but the Hath turned against them. The war has gone on longer as anyone can remember. Thanks to the machine programming, all they know is how to fight… and how to die.
The Hath show Martha a hologram display of the city, while the Doctor goes over a similar map. Cobb talks of how they are seeking the Source, the breath of their Creator. It was lost during the war but both sides seek it. The Doctor manages to access the full system which shows the Lost Temple which contains the Source. It's closer to the human side, and Cobb orders his men to go after it. The Doctor suggests they stop fighting but Cobb insists on wiping out the Hath, but the general locks him and Donna up. Cobb also has the girl, Jenny, locked up as she shares the Doctor's genes.
The Doctor's efforts have shown the Hath the same map, and they prepare to go to the temple.
Locked up in a cell, Donna notices a series of numbered plaques. The Doctor assumes that the Source is not a deity but some kind of weapon or power source. Jenny wonders why he acts like a general despite his supposed pacifism, and looks forward to learning from him. The Doctor calls Martha on his cell phone and realizes the Hath are heading for the temple, but they're cut off when her cell phone battery goes dead.
The Doctor prepares to leave but says Jenny can't come along. Donna attempts to reconcile them and uses a stethoscope to demonstrate that Jenny has two hearts, but the Doctor asserts that Time Lords must share much more than just physiological patterns. He talks about the Time War and how he fought and killed in it, and she wonders how they're different.
Martha's Hath patient brings up a three-dimensional version of the map and she determines a surface route, which is radioactive but temporarily safe. She goes up to take the route, and the Hath goes with her.
Jenny seduces their guard and lures him close enough to capture him and take the key. The Doctor distracts another guard with a toy mouse and then Jenny knocks him out against the Doctor's wishes.
Martha gets to a surface hatch but her Hath is reluctant to go with her. She refuses to let anything stop her, opens the hatch, and steps out onto the barren windswept landscape.
Cobb discovers that the Doctor and the others have escaped, and insists that no one will stop him from acquiring the Source.
As they move through the tunnels, Donna sees more of the numbered plaques and notices that they're counting down. Jenny wonders what the Doctor does and Donna explains about how he saves planets and defeats evil. They come to a laser grid and while the Doctor tries to bypass it, Jenny prepares to shoot at the human soldiers approaching them. The Doctor is disgusted with her resorting to violence, but then she pauses. The Doctor shuts down the grid and gets through with Donna, while Cobb appeals to Jenny as a soldier. She prepares to shoot him… but then severs a gas pipe and releases gas. She heads for the corridor but the laser grid comes back on. She then somersaults her way through the grid, impressing the Doctor, and explaining that she refused to kill Cobb. The Doctor stops long enough to tell Cobb on the other side of the grid that if the Source is a weapon, he'll destroy it.
Martha and her Hath make their way across the surface and she falls into a pit of quicksand. The Hath tries to pull her out and is forced to jump in to lift her to safety, only to sink beneath the surface itself.
Donna tries to explain to Jenny what her relationship with the Doctor is, and how they travel, and suggests that Jenny travel with them. The Doctor agrees and Jenny hugs him. As she runs ahead to scout, the Doctor mentions that he was a father once before and Donna wonders why he hasn't mentioned it before. The Doctor admits that Jenny reminds him of his other children.
On the surface, Martha reaches the tower, while the Doctor's party gets to the temple from underneath. Donna tries to decipher the numbers as the Doctor gets the door open then seals it behind them. The Doctor realizes they're in a spaceship with a functioning fusion drive. He accesses the ship's log and discovers that the mission commander died and the two sides fought for control. Donna sees another number and realizes they all indicate dates that show the completion date for each section. They realize that it's been only seven days since the war broke out, and both sides have gone through twenty generations of reproduction a day via the progenation machines. They find Martha while both the humans and Hath break down the doors to gain access.
Finally, the Doctor discovers the Source: a terraforming device in a transit stage, contained within a gigantic greenhouse. They're interrupted when both sides burst in. The Doctor warns that they can't win and the Source is simply a bubble of gasses generating accelerated evolution. The Doctor offers them hope and a future, then releases the gasses and declare the war over. The humans and Hath lie down their guns… except for the obsessed Cobb, who shoots the Doctor. Jenny leaps in the way and she is mortally wounded. The Doctor says for her to hold on, that they can go anywhere. She says that will be great... and then dies in his arms. She isn't enough like him to regenerate. The Doctor grabs a gun and points it at Cobb… and then says he would never use it to kill. He tells both sides to form a peaceful society, and then sits by Jenny's corpse.
Later, the terraforming process continues while the humans and Hath prepare to give Jenny a proper burial ceremony. In the TARDIS, the Doctor concludes that Jenny's existence drew the TARDIS to her but they arrived early, and now it's time to go home. They drop Martha off and she says that she can't do this any more. Donna says she could never want an ordinary life and she'll travel with the Doctor forever. As the Doctor sees her off, Martha says she wondered if the Doctor had finally found something worth living for, and he says he has. They say their goodbyes and then Donna and the Doctor depart while Martha goes to her flat.
Back on Messaline, a green gas emerges from Jenny's mouth and she comes back to life. She takes a shuttle and declares that she now has the whole universe to explore.