Kirk, McCoy, Chekov, and a security guard beam down to investigate a colony on Beta 12A that reported an attack. The settlement has disappeared without a trace. As they investigate, they're unaware of a hovering ball of energy. Spock reports an approaching Klingon ship but it is stricken with internal explosions. The Klingon captain, Kang, arrives with a landing party and takes the landing party prisoner, and accuses them of attacking his ship.
Kang demands an explanation but Kirk has none. The Klingon demands they turn over the Enterprise to him and when Kirk refuses, Kang prepares to torture them until he yields. A furious Chekov accuses them of killing his brother Piotr and Kang chooses him as the first victim. Kirk finally yields and promises no tricks once they're back on board. Kirk orders everyone to be beamed up but triggers a secret signal on his communicator. The ball of energy winks out while aboard the ship, only the landing party materializes. Scotty has contained the others within the transporter system and only materializes them once a security team is ready. Kang and his men are quickly disarmed while Kirk notes that he only promised no tricks once they arrived. They're unable to contact Starfleet due to interference, presumably from Kang's ship, and start beaming aboard the survivors, including Kang's wife. Kirk dismisses their concerns about torture and Kang and offers them good treatment.
The ball of energy is still secretly aboard the ship and Spock notes the Klingons were too far distant when the distress signal went out. They destroy the derelict Klingon ship but the interference continues and they head for the nearest Starbase. Uhura becomes furious at her inability to establish contact and suddenly the Enterprise accelerates to Warp 9 and the helm controls refuse to respond. Emergency bulkheads come down, sealing off 398 of the crew and only leaving 38 people free. Kirk suspects that Klingons secretly beamed aboard and goes to confront Kang. However, the accessories in the makeshift brig suddenly transform into swords, as does the Enterprise crew's phasers when they try to use them. Kirk and his men manage to fight their way out, although one security guard, Johnson, is badly wounded.
Kirk suspects the Klingons are responsible for the alteration in weaponry, but Spock notes that they'd have no reason to settle for swords, or provide their captors with weapons as well. Chekov goes into a fury, claiming again that the Klingons killed his brother, and disobeys orders to go after the Klingons. After he leaves, Sulu notes that Chekov is an only child. Scotty reveals that something has happened to the bulkheads, making them impossible to cut through.
Spock scans the ship and determines that there are 38 Federation, and 38 Klingons... and one other unidentified life form. Meanwhile, the Klingons take Engineering although Scotty manages to escape. Spock concludes the extra life form is an alien but is unable to determine its motive. They begin to suspect the alien is manipulating not only matter but each group's minds. McCoy storms onto the bridge, uncharacteristically furious with the Klingons' savagery and insisting that Kirk acts like a military man. They try to call Kang who reveals he is cutting off life support to all non-Klingon sections of the ship.
As they work to restore life support, Scotty storms onto the bridge, equally furious over the Klingons. He snaps at Spock who starts to lose his own temper until Kirk restrains them both. Sulu checks in to report he can't override the circuits... just as they come back on. Neither Kirk nor Kang can understand what is restoring the circuits. Spock detects the alien life form and he and Kirk go to confront it. Meanwhile, Chekov has captured Kang's wife, Mara, and starts to assault her, ripping her dress. Kirk and Spock arrive and knock him out, and realize the alien energy life form is nearby. It glows red-hot with energy as they try to get through to Mara without success. They take Chekov to Sickbay where McCoy apologizes for his earlier actions and notes that Chekov's brain patterns have been altered with heightened paranoia. Also, all the injured crewmen, including Johnson, are healing at an accelerated rate, perpetuating the struggle on both sides.
Kirk and Spock take Mara to confront the alien and convince her of the truth, but when they find it Johnson shows up and proclaims himself fit for duty. He goes into a paranoid rant about the Klingons as the entity glows red-hot with energy, until Spock is forced to knock him out. The alien's energy output dies down and they realize it feed on hate and anger. They try to get through to Kang but the alien has influenced him to ignore them.
They go to the bridge as Scotty confirms that the dilithium crystals are deteriorating and they have only 12 minutes left before they are left without power. They decide to threaten Mara to convince Kang to cooperate, but he refuses to listen. Mara prepares for death but Kirk admits it was a bluff. Convinced, she offers to help get Kirk to her husband, and the captain proposes they try intraship beaming to get past the Klingon defense lines. Although its dangerous, Kirk goes with the plan and takes Mara with him, while leaving his sword behind.
Kirk and Mara beam into Engineering where Kang believes Mara has brought a prisoner. Mara tries to get through to him but Kang attacks Kirk, so she tosses the captain a sword. The Enterprise crew fight their way into Engineering while Kirk and Mara try to convince Kang of the alien presence. Finally it shows itself and Kang listens long enough for Kirk to convince him all fighting must stop. They go on the intercom and order their forces to step down, and Spock suggests they engage in high spirits. Slowly at first, the two crew taunt the entity and mock it, until it finally it drifts out into space.