A fly drones on a railway platform. It buzzes around an outlaw, Vin, seated on the platform. He wakes to hear the sound of boots on the wooden platform and he sees a man in overalls approach. This is a railroad worker, carrying a gun. Vin realises that the man will never use the gun, not until Vin has used his. A wind springs up. A third figure in a confederate uniform is visible. The wind increases until the TARDIS materialises. The door opens and the Doctor steps out, eying the guns. He says, 'Hello.'
The group lowers their weapons. The man in overalls calls him 'Doctor'. The Doctor says he doesn't recognise them but they insist he asked them to come. The soldier is Private Bernardo, a deserter, who claims to have met the Doctor in a saloon two days earlier. None of the men has met the others before and the only reason they are there is to do a job with a large reward. This is all that has brought Vin across Texas. Amy steps out, wondering what reward they have offered. She is dressed in appropriate nineteenth century garb. The man in overalls, Hilario, says that they were promised farmland in return for transporting the Doctor's goods. The Doctor is perplexed by this and denies that he has any land to give. He tells them that his 'goods' are half a mile away and all he needs is their help digging it up. Unmoved, Vin tells him that the Doctor said he would say that.
Peering through his binoculars at a Confederate camp, the Doctor agrees that he will need their help after all. There is a dangerous alien device in the camp that needs to be deactivated and returned to the TARDIS before nine o'clock that night. Bernardo tells him that the regiment wouldn't have built fortifications like they have if they didn't regard what they had found as important. He says it is obvious that they are intending to stay a while and will have sent out to the nearby villages for supplies. Probably wine. He suggests that he and Amy will be the best people to approach the camp.
Twenty minutes later they reach the camp. Bernardo produces two skins of wine which he says Amy has brought for the men. They are admitted and walk through the camp, passing a large and freshly dug hole. Nearby some barrels have been arranged around something. Bernardo distributes wine to the men and the two of them use the diversion to explore the barrels. There are some wagons nearby and in one is a golden cylinder the size of two coffins. It has a panel with four flashing lights. They are surprised by an officer who recognises Bernardo as a deserter at the Battle of Galveston. Bernardo recognises the officer as Captain Britt. Britt pulls a revolver out of its holster and puts it to Bernardo's head.
Vin tells the Doctor that the couple is in trouble. Amy throws herself at the Captain and deflects the gun as the trigger is pulled. Amy grabs a horse. Vin takes aim with his rifle and shoots a barrel of gunpowder in the camp. A huge explosion is detonated, and a cloud of smoke rolls across the camp. From within a cart emerges, driven by Amy. Soldiers pursue them. The Doctor leads his two companions back to the station and the TARDIS.
No sooner have they regained the platform than bullets start to hit the nearby water tower and blades of the windmill. The wagon with the Doctor and his friends arrive. He falls out against the TARDIS, leaps up and opens the door. The others try to get the wagon to the door but it won't fit inside. He says he hasn't got the time to materialise around it. Hilario asks what time it is: 3.25. a train sweeps down the track and stops short of the platform. Hilario says he built the tracks and no train has ever been late on them. He runs to the cab, pistol drawn, from which the driver promptly escapes into the desert. The others manhandle the cart carrying the alien device into one of the coaches. Hilario edges the train out of the platform. Britt's men fire a volley into the carriage. The casing of the device is punctured and sets off a really loud distress signal. The Doctor uses his screwdriver to cut out some of the noise. Amy checks the train to see if anyone else is on board.
Bernardo asks what the device is. The Doctor tries to tell them about an interplanetary war and that the device is a terraformer to allow one of the ships from the losing side to colonise Earth. He says that if he doesn't stop it everyone will drown. A bullet hits Vin in the shoulder. The Doctor uses his screwdriver to magnetise the bullet and pulls it out. He slips it into his pocket.
Hilario races the train through the barren landscape in pleasure. Behind he can see soldiers boarding the train from their horses. Five men scramble onto the carriages. The Doctor works his way back to find Amy. One soldier attacks the Doctor as he tries to leap from carriage to carriage. The Doctor swings helplessly until Bernardo knocks the soldier off the train with Vin's empty rifle and hauls the Doctor back aboard. The Time Lord then opens the hatch in the roof of the second carriage and the two men climb out to send two soldiers off the train. They run down the roof, too late, to see the last carriage uncoupled. They see Amy waving forlornly as the train pulls away from her.
The carriage trundles half a mile until it halts. Britt and his men arrive and the captain pulls her off the train. He asks her name. She tells him that she is 'Miss Pond'. He promises that she won't come to any harm unless she refuses to answer his questions. She tells him that the device is a Cei terraformer and that she was trying to get it off the planet before it went off at nine o'clock. He doesn't believe her and bundles her onto the back of his horse to return to the camp.
Sometime later she sees a silver disc sweeping across the sky. It is the Cei ship, she tells them. It is hovering over their distant camp. Green lights search the camp. They turn red and then an explosion erupts from the camp. The ship moves over them and away. Britt tells them that there will be no survivors in the camp. Amy notes that the ship is following the train and she says that if the Doctor fails it is because Britt stopped him. She taunts the captain into following the train with her.
The Doctor tries to wire the terraformer to a small metal box he pulled from his pocket. He is disconsolate. Vin checks his shoulder and guesses that he won't be able to shoot again. He says he is forty and too old to start again with a new life. He adds that the world might be a better place if everyone was like Bernardo and ran away from battles.
The Doctor explains that he is trying to build in an inhibitor to limit the device's radius to a few miles. Bernardo calls him to say that the saucer is approaching. Hilario is prepared to give the saucer a race and opens the throttle only to see a sign saying 'Soledad Valley'. He tells the Doctor that this is where the track runs out, half way across a thousand foot bridge. He says that they are going to have to jump for it. The Doctor says that he has finished his alterations to the cylinder.
The four men leap from the train, the Doctor being the last to go. He rolls over a precipice and grabs a bush. He looks across to see the train plunge off the bridge into the valley below. Hilario pulls him up to the track. The saucer upends itself and buries itself in the desert floor. Hilario and the Doctor approach. Britt suddenly appears, too, with Amy. Britt claims the starship for the Confederate army and hammers on the hull with his gun handle. The Doctor watches with interest. Amy hugs him and they inspect each other's tattered clothes.
A hatch opens high on the hull of the ship. A golden haze emanates and then a hunched and spindly shape moves out. A skull-like helmet encases the face and an ivory exoskeleton sheaths its body. The Doctor recognises it as the Cei leader. It leaps down among them and asks who has interfered with the terraformer. The Doctor says it was him and asks what of it. He says that the Cei thought the planet too primitive to be noticed when they committed genocide. Britt is angry because he thinks the Doctor stole his weapon and threatens the alien with his pistol: if the Cei doesn't hand over the terraformer and the spaceship he will put a bullet in its brain. The alien flicks its wrist and a gun of its own unfolds.
Slowly, the Doctor raises his fist to show a watch. He tells them that it is nine o'clock. A shock wave ripples across the desert from the terraformer. Grass, pine trees and fog roll out to replace the desert with a paradise. Britt is knocked down by the force of the blast. Vin points a gun at him and Bernardo does the same to the Cei. Amy asks what the Doctor did. He says he reprogrammed the Cei device to create an Earth environment. He turns to the men beside him and tells them that this is the farmland he promised.
Amy pushes Vin's gun away, saying he has children. Vin says that his gun was empty anyway. The Doctor helps the Cei to its feet and gives it a small metal bauble. He tells it that it is a hyperdrive booster to help the craft get home.
Amy and the Doctor stroll into the sunset. She asks how the trio of men knew to meet them at the railway. He picks up the pace towards the TARDIS, telling her that they have some recruiting to do.