Stardate 4842.6: Kirk, Spock, and McCoy beam down to a planet that is in the path of an oncoming asteroid. They note that the planet has an environment similar to Earth. As they explore, they find a large metal obelisk made of a substance that is resistant to tricorder probes. It is engraved with symbols but Spock is unable to translate. He believes the technology of it exceeds their own. Although they have 30 minutes until they have to depart to arrive at the deflection point in time, they investigate the largest cluster of nearby lifeforms.
The local people bear a strong resemblance to Earth's American Indians, selected from those among the more advanced or peaceful tribes. Kirk admires their peace and calm, and McCoy notes it's representative of Tahiti Syndrome. There's no point in their warning the natives and starting a panic, so they return to the obelisk for one final look. Kirk goes on ahead and examines it briefly, then calls Scotty on his communicator. When he does so, a panel opens and Kirk falls into a chamber within. He touches a panel and a beam of light strikes him in the head, causing him to collapse.
Spock and McCoy are unable to find the captain. Spock orders departure over McCoy's objection, warning that if they don't reach the deflection point in time the planet will be destroyed. Once they divert the asteroid, they'll return to find Kirk. After they depart, Kirk recovers consciousness and discovers that he has no memories of himself, his ship, or his equipment. He goes outside and finds two of the local women approaching the obelisk with offerings. They bow before him and then one of them, Miramanee, takes his hand and says they are his people and have been waiting for him to come.
Scotty warns Spock that as they make all possible for the speed to the asteroid, they're in danger of burning out the engines. Spock acknowledges the danger but notes they have no choice but to proceed at Warp 9.
At the Indian village, the tribal leaders lead by Chief Goro, question Kirk's credentials. The medicine chief, Salish, demands that Kirk prove himself. Kirk admits he came from the temple and from the sky, but nothing beyond that. They're interrupted when Miramanee and the others bring in a boy who drowned in a fishing accident. Salish declares him dead but Kirk administers mouth-to-mouth resuscitation and revives the boy. The people accept that as proof that he's a god and Goro forces Salish to turn over the badge of the medicine man.
The Enterprise arrives at the deflection point and use deflectors at maximum power. They fail to shift the asteroid and Spock orders them directly into the path of the asteroid. They will then use phasers at full power to shatter the asteroid.
Miramanee is returning from the lake when Salish confronts her. She reminds him that as the tribal priestess, she must marry the medicine man and she is now betrothed to Kirk. He doesn't wish to marry anyone else, and wonders if she would choose him if she could. Miramanee doesn't respond. Instead she goes to Kirk and he asks about the wise ones. Miramanee tells of how they gave the secrets to the medicine chief, but Salish's father died before he could pass on the secrets. Goro arrives and asks what name they can refer to Kirk by. He vaguely speaks his name and Goro hears it as "Kirok." The chief wonders if they have displeased him and Kirk assures them that they have not, and that he feels at peace there. Miramanee touches him and assures him he'll have the time he needs.
Chekov finds the asteroid's weak spot and they open fire. As they fire in sequence, the relays burn out.
Miramanee comes to Kirk and informs him that she is betrothed to him by tradition. He wants no one else and says that they can be joined in marriage the next day.
Spock is studying pictures of the obelisk when Scotty informs him that they've lost warp drive. They have no chance of repairing them and can only proceed on impulse. Spock orders a course back to the planet over McCoy's objections. The doctor orders him to get some rest and departs.
At the obelisk, Goro begins the ceremony. Kirk is to go on ahead. Salish intercepts him and prepares to kill him rather than allow the joining. The former medicine chief attacks him with a knife and draws blood, and realizes he is no god. Kirk defeats him but refuses to kill him despite Salish's vow that he will show the people he is no god. Kirk goes on to the lodge, dons the ritual cloak, and is joined with Miramanee.
Fifty-eight days later, Spock is trying to decipher the writing on the obelisks, well aware they'll only have four hours to effect rescue. He insists that the obelisk is the key to stopping the asteroid but McCoy insists that he get rest. Spock reluctantly agrees. However, once McCoy leaves, Spock returns to his computer terminal and continues studying the obelisk.
As the months progress, Kirk and Miramanee are happy together. However, Kirk is still plagued by dreams of the strange lodge that moves through the sky and faces of people that he believes he should be with. She tells him that she is pregnant with her child. Kirk begins to develop advanced technology, irrigation, and lamps, but the skies grow dark and the wind increases. Miramanee tells him it's time for him to go to the temple and save the people. Kirk has no idea what to do. Goro and Salish come to ask for his help. When he can offer nothing useful, Salish challenges him and Kirk goes to the obelisk. He has no idea what to do and throws himself at the side of the obelisk as Salish looks on.
Onboard the Enterprise, McCoy discovers that Spock isn't sleeping. Rather, he's playing the Vulcan lyre and has concluded that the symbols on the obelisk are musical notes. The obelisk was left by an ancient race named the Preservers who seeded the galaxy with primitive cultures in danger of extinction. The Preservers placed the obelisk as an asteroid deflector but it has become defective.
The tribe comes to the obelisk. Miramanee goes to Kirk as Salish incites the people, who stone Kirk and Miramanee. The Indians run when Spock and McCoy beam down. They beam down Chapel with an emergency surgical kit. Kirk has no idea who they are and calls out to his wife. Chapel does what she can while Spock uses a Vulcan mind meld to try and restore Kirk's memories. The process succeeds and Kirk briefly checks Miramanee. When Spock explains that the obelisk is triggered by sound, Kirk recreates the words he spoke when he fell inside. The door opens and he and Spock go inside. Spock is able to analyze the technology and activate the deflection beam.
Back at the lodge, McCoy informs Kirk that Miramanee is dying of her injuries. Kirk goes to her and she is happy that he is safe. He assures her that her people are safe. Miramanee promises things will be better once she is better. They kiss one last time before she dies.