"Patterns of Force" by John Meredyth Lucas
Goodyy, just what I need, a preview of our possible future...
The Enterprise goes to the planet Ekos to find out what happened to historian and cultural observer John Gill. A rocket with a nuclear warhead is sent at the ship and destroyed.
There's more humor and snark than I remembered (or expected).
Interesting commentary on teaching: "What impressed me most was his treatment of Earth history as causes and motivations rather than dates and events." (I personally found I learn more from fictional dramatizations of history for just this reason.)
Subcutaneous transponders were a good idea. I wish they'd used them more often when undercover.
Kirk and Spock beam down and find Nazis and that their Fuhrer is John Gill. They try to reach Gill but get caught. Spock's ears are a constant problem in this episode.

They get whipped and interrogated by Party Chairman Eneg. They also meet Isak, a Zeon prisoner. Using their transponders, they fashion a crude laser and escape the prison. They go to the lab and find their communicators have been disassembled and their phasers are missing.
Isak takes them to meet the underground resistance led by his brother Abrom. Spock assembles one communicator from the parts. Their hideout is raided by Daras, who they had previously seen receiving a medal, in what is quickly revealed as a ruse to test the strangers' loyalty.
The Fuhrer is making a speech that night about the "Final Solution." Kirk and Spock explain who they are and that Gill is from the Federation. Posing as a camera crew, Kirk, Spock, and Isak follow Daras into the room where the top party leaders will be hearing the speech. Spock sees Gill in the broadcast booth and he seems unresponsive. Kirk decides he needs McCoy to tell him what's going on with Gill and McCoy beams down. They are found by Chairman Eneg, who doesn't seem to recognize them. We find out later he's with the Underground.
SPOCK: Captain, the speech follows no logical pattern.
KIRK: Random sentences strung together.
They get into the booth after the speech and McCoy determines Gill is drugged. He gives Gill a stimulant and Spock uses a mind probe on him. Deputy Fuhrer Melakon has been drugging Gill and leading in his name.
KIRK: Gill. Gill, why did you abandon your mission? Why did you interfere with this culture?
GILL: Planet fragmented. Divided. Took lesson from Earth history.
KIRK: But why Nazi Germany? You studied history. You knew what the Nazis were.
GILL: Most efficient state Earth ever knew.
SPOCK: Quite true, Captain. That tiny country, beaten, bankrupt, defeated, rose in a few years to stand only one step away from global domination.
KIRK: But it was brutal, perverted, had to be destroyed at a terrible cost. Why that example?
SPOCK: Perhaps Gill felt that such a state, run benignly, could accomplish its efficiency without sadism.
KIRK: Why, Gill? Why?
GILL: Worked. At first it worked. Then Melakon began take over. Used the. Gave me the drug.
Guards arrive and Kirk makes it look like Daras captured Spock in the booth. Spock is taken to Melakon (who does a rather funny appraisal of him). Kirk gives Gill another stimulant, getting him cogent enough to speak, and Gill calls off the slaughter of the Zeons. Melakon grabs a machine gun and fires at the broadcast booth, killing Gill. Isak kills Melakon.
Dying, Gill tells Kirk he was wrong. Eneg and Daras agree to "stop the bloodshed", and plan to announce the end of the Nazi regime. Kirk, Spock, McCoy go back to the Enterprise, where Spock and McCoy banter about "Absolute power corrupts absolutely."
Despite the inherent crazy of the premise, it's a damn good episode. The acting is excellent and the writing is sharp. It kept my attention all the way through.