Investigating a planet in danger of collision with an asteroid, Captain Kirk, Mr. Spock, and Dr. McCoy discover both Native American inhabitants and a strange alien obelisk. While examining the obelisk, Kirk is accidentally trapped inside. Trying to escape, he inadvertently triggers a device that gives him amnesia.
Unable to locate the Captain, Spock and McCoy return to the U.S.S. Enterprise to try and stop the asteroid from hitting the planet.
Now free from the obelisk, Kirk is found by the natives, who come to believe Kirk (calling himself Kirok with his damaged memory) is a god. Kirk both becomes the tribe's medicine chief and marries the priestess Miramanee.
Meanwhile, the U.S.S. Enterprise fails in its attempt to destroy the asteroid. Spock is able, however, to translate the obelisk's carvings. He learns that an alien race known as the Preservers transplanted the Indians to this world, and provided an asteroid deflector inside the obelisk to protect them.
Returning to planetary orbit, Spock and McCoy beam down. They find the natives, frightened that Kirk does not know how to use the obelisk to protect them, stoning Kirk and Miramanee. Rescuing the pair and restoring Kirk's memory, Kirk and Spock enter the obelisk and activate the deflector. The planet is saved but Miramanee, pregnant with Kirk's child, dies from her injuries.