When the U.S.S. Enterprise finds that all the adults in the Starnes Expedition to Triacus have killed themselves, they beam to the planet's surface to investigate. The children, however, are alive and well and strangely oblivious to their parents' fates.
They are beamed aboard the U.S.S. Enterprise while Kirk searches for an answer to the strange occurrences. The children summon their "friendly angel" Gorgan, who tells them to take the U.S.S. Enterprise to a planet he can control. By garbling Kirk's words and deceiving Spock, the children are able to take control of the starship. Finally, seeing Kirk's anxiety at the loss of his ship, Spock realizes that something is wrong and helps the Captain regain control.
Kirk shows the children tricorder tapes of their parents ... and their graves, demonstrating to them that Gorgan is not a "friendly angel" but an evil force. The loss of his believers renders Gorgan impotent and he fades into oblivion.