When Dr. Simon van Gelder of the psychiatric staff at the Tantalus Penal Colony escapes to the U.S.S. Enterprise exhibiting signs of manic insanity, an enraged McCoy insists that Kirk investigate the colony. The Captain reminds McCoy of Tantalus' excellent reputation, but McCoy is unconvinced.
Kirk and Dr. Helen Noel, the U.S.S. Enterprise's psychiatrist, tour the facility. They discover that the Colony director, Dr. Tristan Adams, has been using a brainwashing device, the neural neutralizer, to control not only the colony's inmates, but his staff as well. When the doctor realizes that Kirk has discovered his secret, he convinces the captain to try the machine for himself, to prove that it is perfectly safe. The result is that Kirk falls madly in love with Helen Noel and the two remain on the Colony as Adams' prisoners.
Meanwhile, on board the U.S.S. Enterprise, van Gelder is in such a distraught state from the neural conditioning that he is unable to explain to Spock what is going on at the penal colony. The Vulcan attempts a mind-meld with van Gelder and discovers what has been happening on the planet below. On Tantalus, Dr. Noel escapes through an air-conditioning duct to the power room, where she lowers the planet's defense shields, enabling Spock to beam down a security team.
Kirk recovers enough to fight Adams, who falls into his torturous machine. Weakened by the conditioning and his fight with the doctor, Kirk stumbles away, not knowing that Adams is still in the neutralizer. Adams is later found dead. Dr. van Gelder is made sane again and returns to direct the Tantalus Colony.