Stardate not given: The Enterprise approaches the planet Omega 4 and spots its fellow starship the Exeter. There's no response to their hail and Kirk takes Spock, McCoy, and Galloway over to investigate. They find empty uniforms and piles of crystals, and a search reveals no one aboard the starship. Kirk and McCoy go to the bridge and meet the others, and McCoy determines that the crystals are all that are left of the crew after all the liquid was removed. Spock brings up the surgeon's log and the doctor warns them that the planet grants immunity and Tracey is on the surface.
The team quickly beams down to the planet and finds itself in a primitive city. They come upon an execution where the locals are preparing to decapitate one of two "primitives." The locals spot the landing party and pause, but Tracey shows up to orders the natives to back down. The local head man recognizes the phasers but follows Tracey's instructions to lock up the primitives, the Yangs. Tracey explains that he stayed on the planet to negotiate with the locals, the Kohms, while the rest of his party beamed up to the surface and carried the disease with them. Tracey explains there's a factor on the planet that immunizes anyone, and they'll only stay alive as long as they remain on the planet.
Kirk begins to suspect that Tracey has been interfering with the local culture, while McCoy concludes the disease similar to one developed on Earth during the Cold War. Spock comes in with a wounded Galloway, who was injured during a Yang ambush. Spock notes that Tracey is correct that the Yangs are vicious savages that are massing for an attack. He has also found discharged power packs indicating Tracey drove off an earlier attack with his phasers. Kirk tries to warn the Enterprise but Tracey pulls a phaser on him. When Galloway goes for his phaser, Tracey disintegrates him. He then signals up to the ship and tells Sulu that the landing party was temporarily overcome by the disease. Kirk tries to yell out a warning and is knocked out for his troubles.
Kirk is tied up and left guarded, but quickly knocks over the man until Tracey arrives to stop him. They then discuss the situation and Tracey explains that the natives are immune to disease and some have lived as much as a thousand years old. Tracey wants Kirk to get McCoy to distill the necessary elements then they can sell it to the galaxy, but meanwhile they have to hold off the Yangs. Kirk manages to cut through his bonds but Tracey readily dispatches him then has him thrown in a jail cell with the two Yangs while Spock is in the neighboring cell.
The male Yang attacks Kirk, who is forced to struggle for his life. The female Yang backs into Spock's cell and he renders her unconscious with the Vulcan nerve pinch. The male Yang relents to tend to her. Kirk tries to get through the barred window as Spock speculates that the two cultures once tried to destroy each other and the current people are the remnants of those more advanced civilizations. When Kirk mentions "freedom," the Kang takes an interest and refers to it as a "worship word." Kirk works on the window bars again and the Yang helps him. They get the bar out and then the Yang, Cloud William, knocks him out and he and his mate Sirah escape.
Kirk wakes up seven hours later and they find the keys and get out. They sneak in to see McCoy, who reveals that the immunizing agents take a few hours to act and they can leave any time they want. McCoy further notes that Tracey's theory is incorrect and the locals only live a long time because their ancestors built up an immunity during the war, giving only them a long life. Spock rigs a crude communicator but Tracey disintegrates it, burning Spock. Tracey relates how he had to shoot down hundreds of the Yangs but more came until he ran out his other power packs. McCoy explains to Tracey the reality of the locals' longevity and the shocked captain orders Kirk outside. Tracey demands that Kirk order the Enterprise to beam down more phasers. Kirk gets the jump on him then runs for it, and Tracey tries to disintegrate him. The Exeter captain corners him but his phaser runs dry. Tracey grabs an axe but before he can kill Kirk the Yangs arrive and take them both captive.
Spock and McCoy are brought in to where the Yangs are holding their victory celebration with Cloud William presiding. Kirk concludes that the Yangs are what Americans might have become if forced to move to the wilderness, and concludes the Yangs are the Yankees, and the Kohms are the Communists. On this world the Asiatics won. Cloud William declares victory and the Yang flag is brought in: the American flag.
Tracey is brought in and warns them not to fight him or he'll drag them down with him. Cloud William start to recite a gibberish chant which Kirk recognizes as the Pledge of Allegiance. Kirk tries to explain but Tracey claims Kirk was cast out as a devil and he's using their holy words to trick them. Tracey points to Spock as a devil and when they can't detect a normal heart beat, consider Tracey's words. Cloud William note that only the good can speak the sacred words and recites the first few words. Kirk vaguely recognizes them but can't finish the recital. Kirk suggests that since good is stronger than evil according to their holy book, he and Tracey should fight in a trial by combat.
The two captains are tied together at the wrist and left a single knife to fight over. While the men struggle, Spock manages to make mental contact with Sirah and "persuades" her to give him a communicator. Kirk gets the knife but spares Tracey's life, as Sulu beams down with two security men. They arrest Tracey and Kirk explains that he is no god but just a man. Kirk opens the chest holding the holy papers and recites the sacred words: a bastardized version of "We, the People of the United States…." Kirk insists that the words are for everyone, even the Kohms. Cloud William vows to try and fulfill the words as best he can. As they leave, Spock wonders if they've violated the Prime Directive but Kirk says they've only given them a push and they leave to let the Yangs and Kohms find their own path.