Shij˘ Sada wakes and wonders why. He watches dawn over the village. He can feel that something dreadful is coming. He ascends the mountain to the shrine to see if he can find an answer. The shrine glows in the mist. He enters the gates and hears two voices: the Doctor and Amy bickering over where they have arrived. Shij˘ Sada recognises that they don't belong in medieval Japan. The Doctor is trying to trace a signal.
Shij˘ watches them come round a corner towards him and puzzles over where they came from and why the young woman appears to be wearing only underwear. He steps out to meet them and bows. He is impressed with their facility with his language. He introduces himself as the elder of the village. The Doctor warns him that wherever he and Amy arrive terrible things seem to happen.
Amy is impressed by the shrine's guardians. They are huge mannequins made from animal skins over frames: fanged and clawed. He calls them Otoroshi. He adds that the shrine is famous for the jade pyramid at its heart. He is sad that only monks may look upon it and so he can't show it to the Doctor. The Doctor tells Amy that the distress signal that the TARDIS picked up an hour earlier has faded.
They step back away from the shrine. Amy notices that one of the Otoroshi turned its head to look at her. The Doctor seems not to believe her and then again he might. Shij˘ says that the Shogun has sent seven Samurai to take the jade pyramid back to the imperial court. The Doctor wonders if the pyramid is alien tech and the source of the distress signal.
The village welcomes the Doctor and Amy. The Doctor is invited to a meeting of the villagers in a large airy room later that evening. A small, crooked man Tanaka seems to be challenging Shijo's authority and suggesting a forceful defence of the pyramid. He is interrupted by a large, overweight man. Shijo tells the Doctor that he is a man who operates as a masterless Samurai. His name is Nasu and he is in a curious position somewhere between disgrace and prestige. The villagers listen to him respectfully but not completely. He says he cannot train the villagers to fight Samurai and the Doctor agrees that such a battle would be a massacre. Tanaka is contemptuous and says they have nothing to lose. He is obviously more concerned about the taxes that are exacted by the Shogun.
The Doctor looks around for Amy and sees that she has gone. She has made a bee line for Nasu and decided he will be the ideal person to lead her to the door in the shrine that she was forbidden to enter. She asks him to guide her. Amused, he agrees. They climb back up to the shrine. Amy is hoping to find the alien craft that the Doctor has suggested might be in the shrine. It is dark by the time they pass the Otoroshi and the warrior lights torches for them. Amy tells him she has left 'something' behind the inner door. Nasu is surprised - he seems to know that it is forbidden to enter but permits her to enter. They pass through to the jade pyramid. Amy is disappointed to find it is only slightly bigger than her fist. She approaches it and as she does she notices through a window that the Otoroshi have gone. She looks up and sees that they are in the room with her, clinging to the ceiling above with their claws ready to strike.
The meeting breaks up with the villagers keen to do something to protect the region of Kokan and the pyramid but with nobody clear how they intend to do it. The Doctor spots that Amy and Nasu have left together. A boy rushes in to say that the Imperial Samurai are only a few miles away, camped on local farmland. Shijo decides to go to talk to them and the Doctor says he will go too. Shijo agrees and the two sneak off to the stables and ride out to the farm. A star shaped weapon narrowly misses them and embeds itself into a tree. Shijo throws himself to the ground, warning the Doctor that a Ninja assassin is attacking.
An Otoroshi swipes its claws and Nasu pulls out his sword and swings at the ogre. The other Otoroshi drop to the floor and attack silently. Nasu dodges and pulls Amy with him into the next room and then outside. The Otoroshi pursue them but stop at the outside of the temple. They then resume their original positions as though they had never moved. Amy and Nasu make their way down the hill.
Nasu pulls Amy to the floor and clamps his hand over her mouth. He shows her a black-clad figure ahead and, beyond them, two horses and the Doctor and Shijo. Nasu heads down to help. The Ninja fires at the Doctor with a blowpipe. Nasu roars and attacks. The Ninja spins and throws a chain around Nasu's legs, dragging him down and aiming a sword strike at him. Nasu topples the Ninja over and forces him to retreat. Amy scrambles down to him and arrives at the same time as Shijo and the Doctor. Shijo is bleeding from a wound to his face. He mutters, 'Poison' and dies. His last words are that Nasu should be next and that Tanaka is not to be trusted. Amy tells the Doctor how small the pyramid is as they walk back to the village. The Doctor says it is clearly alien.
Back in the village, everything has changed. Tanaka has admitted the Imperial soldiers. The fatal attack on Shijo was part of his plan and he has declared himself the new village elder. He tells the Doctor and Amy that they will be executed in the morning. They are locked into a makeshift prison in a village house. Nasu, meanwhile, has managed to sneak away. Amy is put into one room while Amy is in another. There is another prisoner in the room with the Doctor and he wakes up; a wild haired stranger who owned the farm that the Samurai camped on. His name is Hiko and he was once a monk at the temple and he tried to defend his land against the Samurai. He tells them that there is a room beneath the jade pyramid where people who are sick recover much more quickly. There is also a metal corridor. The Doctor is intrigued by this corridor but before he can find anything out he finds that there is an Otoroshi behind him. Amy can see its large silhouette through the paper walls. She sees movement and a fire break out. The Doctor laughs and then Nasu is brought in wearing what looks like an Otoroshi skin. He explains that Hiko and the Doctor have gone somewhere else but where, he does not know. He also knows that Tanaka took some soldiers and the Samurai to the shrine. They were attacked by the Otoroshi who proved invincible, apart from one that slipped over a cliff. He found the inert Otoroshi and took the coat for his breakout attempt. Accidentally knocking over a lamp started a fire which allowed the Doctor and the farmer to escape. Tanaka appears again with the three surviving Samurai. He announces that he will attack the shrine again at daybreak.
Amy and Nasu, arms tied behind their backs, accompany Tanaka and his soldiers back up the hill. Amy spends her time complaining until Tanaka unsheathes a sword and threatens to execute her. She stops him by telling him she knows his secret. This stops him in his tracks. She is delighted that he is gullible and wonders what his secret might be. She tells him that there is a discrepancy between the taxes raised and those paid to Kyoto. He laughs and says that he will blame the villagers for not paying. She tells him that the pyramid is more important than he realises and attempting to take it will cause a massacre.
Tanaka shoves her to the ground. He brandishes the sword. The three Samurai step in, having overheard his confession. They tie him up. He protests that they were too far away to hear his conversation but Amy had ensured it took place within a natural stone circle that amplified their words and carried them to the Samurai. The soldiers haul the girl and Nasu back onto the path and on their way to the temple.
The Doctor's priority has been to get to the shrine and switch off the Otoroshi. He wants to know what is at the end of the corridor and how the monks passed the Otoroshi so easily. He arrives at the shrine and finds it littered with the bodies of dead soldiers and a handful of Samurai corpses. Down the slope he sees the party approaching from below. He sees a green disc around Hiko's neck and asks to look at it. It was given to him when he was a monk, the farmer explains, and he kept it when he left the order. The screwdriver reveals it as electronic, emitting a signal that announces the wearer as a friend to the Otoroshi. He adjusts the screwdriver to duplicate the signal.
They go to the inner room. The Otoroshi remain outside. Looking at the jade pyramid he sees that it is the source of the distress signal he received in the TARDIS. He picks it up and follows Hiko down a tunnel to a large cave. There is unusually oxygenated air in the cavern. He asks Hiko to show him the metal tunnel. They run down and arrive at a silver door. It has a recessed triangle. He places the pyramid in like a key and the door opens. The Doctor wonders if they have opened a prison or a tomb.
Amy is apprehensive when they arrive at the shrine. The Samurai and soldiers draw their swords. A single soldier is sent to get the pyramid. The Otoroshi attack the waiting soldiers. Amy begs the Samurai nearest to her to retreat but he refuses.
The Doctor looks around a vaulted chamber full of couches and life support machines. He tries to find information from a console and declares that they are in a medical room of a spaceship that has been there for centuries. The crew was benign explorers who were killed by locals; the Doctor sees a cabinet occupied by the body of a local man: he was sick when the aliens arrived and they tried to heal him. He says that the Otoroshi are guarding the man in the chamber. He wonders how the Otoroshi and the control discs are intertwined with the life of the village. He says that the technology of the ship must be kept hidden from everyone. A silver android enters the room and runs across the ceiling.
An Otoroshi lands near Amy in its battle with a soldier. It suddenly comes to a halt. The other Otoroshi do the same. The troops cheer (the surviving ones anyway). A soldier reports that the pyramid has gone. The Samurai search for the thief or his means of exit from the chamber but find nothing. Instead the warriors wonder why Nasu has not sought his own death. He replies that Amy has done nothing wrong. They release her. Nasu tells them that the Otoroshi attacked because they objected to the pyramid being taken by force. The gods have taken it he says. The Samurai consider this and decide to take Tanaka for trial in Kyoto. They say that the villagers should elect a new elder. The Doctor appears, as if from nowhere, and suggests Nasu. The Samurai say that they will bury the dead and then on their long journey home they will think of what to tell the Shogun about the fate of the pyramid.
Later, the Doctor tells Amy that he ordered the Otoroshi in the ship to block up the entrance after he drained the battery to switch the Otoroshi on the surface off. He left the healing mechanism on, however, so that the shrine would retain some of its fabled powers.