The influence of Star Trek stretches into some surprising corners of pop culture -- places that fans wouldn’t normally associate with such a bright and optimistic franchise. But Gene Roddenberry always envisioned the show as smart science fiction engaging with strong ethical issues, which in turn made it easy to imprint on other sci-fi properties of a similar bent. One particular episode of Star Trek: TOS extended all the way into the Purge franchise -- dystopian films about our collective inhumanity that are about as far from the positive future of Star Trek as the dark side of the moon.

The episode in question is Star Trek Season 1, Episode 22, “The Return of the Archons.” According to These Are the Voyages: TOS Season One, it was one of the three script pitches Gene Roddenberry used to sell Star Trek in the first place. It dealt with what have now become classic Trek dilemmas – violation of the Prime Directive and the dangers of artificial intelligence – combined with a meditation on the power of the unthinking mob.

RELATED: Star Trek: There Are Two Answers to Who Has Appeared in the Most Episodes

The episode entails a mad computer named Landru – built by a leader of the same name thousands of years before – who rules a planet by keeping its populace in a constant state of mindless bliss. Kirk and the Enterprise find a stagnant population living blank, happy lives -- save for a periodic “Festival” which engulfs the civilization in lust and riots. At “the red hour” of 6:00 PM, the people suddenly go mad -- raping, looting and destroying everything in their path. Certain citizens are spared from having to participate in the Festival -- mostly due to advancing age -- but the event is considered an act of religious faith and denying it is tantamount to blasphemy.

Kirk and Spock dispatch the computer in a finale straight out of The Wizard of Oz -- firing phasers through a projection of the planet’s “ruler” Landru to find a boxy machine humming quietly behind it. It created a society without conflict at the cost of imagination and advancement, which Kirk sets right by inducing Landru to destroy itself. The irony worked well as a climax, but the bulk of the episode concerned itself with the devotion of the populace to Landru’s dictates. It became a chilling metaphor on how monstrous events can be accepted as normal, and how a certain amount of violence is always present in the human soul.

RELATED: Star Trek: How Picard Homaged One of Sci-Fi's Most Important Writers

Those were the themes that writer-director James DeMonaco wanted to explore with 2013’s The Purge. In an interview with Birth. Movies. Death., he cited “The Return of the Archons” as a huge inspiration, explaining that his father used to watch it with him all the time. The movie posits an America of the near future, where a group of politicians called the New Founding Fathers have seemingly created paradise. Social ills are a thing of the past, and crime and unemployment sit at historic lows.

Two killers from the film The Purge.

They credit this miraculous development to “The Purge,” a yearly holiday in which all crime is legal within the United States for 12 hours. The resulting violence becomes normal – akin to Super Bowl Sunday – and the attendant social benefits arise because the most vulnerable members of society – minorities, the poor and the homeless – are often killed en masse during the Purge.

The film went on to spawn a prequel and three sequels -- the latest of which is due for release on July 2. All of them embrace the same central theme as “Return of the Archons”: an implied religious fervor turning acts of horrific destruction into an ordinary part of life. Star Trek had the benefit of setting it on an alien world in the far future, letting it add the twist with the computer to create an additional layer between the story and its audience. The near future of The Purge feels much closer, something that has helped drive the horror film franchise to success. It’s less a sign of how distant Star Trek was from our world and more that Roddenberry’s space opera always understood a great deal about human nature.

KEEP READING: Star Trek: Some Victims of Borg Assimilation Look Different - and There's a Good Reason Why