The following post contains SPOILERS for Star Trek Into Darkness and Star Trek Beyond.

The entire marketing campaign and dialogue around Star Trek Into Darkness — not to mention most of the runtime of the actual movie — was about the mysterious identity of its villain. Who was this guy Benedict Cumberbatch is playing? Was he an old character from an earlier movie? Could he be Khan? Oh, no, he’s “John Harrison.” Wait, who the hell is John Harrison? Why all the secrecy around a nobody named John Harrison? Are we sure he’s not Khan? No, J.J. Abrams insisted he wasn’t Khan and he wouldn’t straight up lie to our— whoops no, never mind, he straight up lied, he’s Khan.

Star Trek Into Darkness spent so much time building up a twist that everyone in the audience either knew was coming (because they knew Star Trek lore and recognized the iconography) or didn’t care about (because they didn’t know Star Trek or Khan or why he mattered). In contrast, Star Trek Beyond has invested almost no energy puffing up its villain, an alien tyrant named Krall (Idris Elba), and ironically when his origin is revealed, out of nowhere, it does make an impact. And it turns a previously one-dimensional bad guy into the focal point for all of Star Trek Beyond’s ideas.

For the first two-thirds of Star Trek Beyond, Krall appears to be a power-mad and bloodthirsty leader of his own band of ferocious soldiers. Marooned on a planet in deep space, Krall and his men lure the Enterprise into a trap, destroy the ship and kidnap its crew. It turns out the Enterprise is in possession of an ancient totem of little value to them but huge value to Krall. This, we later learn, is a weapon of intergalactic mass destruction. Krall wants to use it to inflict his revenge on the Federation.

Krall keeps his motives close to the vest, but eventually Lt. Uhura (Zoe Saldana) recognizes him in a video recovered from the wreckage of an old Federation ship. Krall was actually its captain and, before that, a soldier in the military organization that protected Earth prior to the establishment of the peaceful Federation. Stranded on this distant planet, Krall went mad and then used the technology he found to extend his life as a kind of energy-sucking vampire. Leeching the life essence of others allowed him to live for decades but further warped his mind along with his body.

Before the revelation of Krall’s human backstory, he seems like a product from a Hollywood screenplay factory. A force of unstoppable strength and unambiguous evil, Krall only craves destruction, chaos and murder with little nuance or moral shading. He says he comes from a planet of constant war and terror. “Struggle,” he adds, “made us strong.”

He stands in direct opposition to the Enterprise crew’s values and beliefs. They preach “strength in unity,” diplomacy and diversity. In dialogue and in action, writers Simon Pegg and Doug Jung repeatedly reinforce the notion that the heroes of Star Trek prevail because of their teamwork, and of the magic that happens when disparate people from different backgrounds combine their unique skills. (The solution to defeating Krall is developed, on the fly, with contributions from every key member of the Enterprise crew.)

I’ve read many Star Trek Beyond reviews that call Krall a “generic” villain. The Verge’s Tasha Robinson said he was “about as generic a baddie as the Trek movies have provided to date.” Flavorwire’s Jason Bailey cited him as one example of Hollywood’s wider “generic villain problem.” For most of Star Trek Beyond, I agreed with them. Krall does seem generic; he even looks like a bunch of other previous Star Trek bad guys. But I’ve come to believe that was all by design.

Making Krall generic in the first two-thirds of the movie allows viewers to dismiss his ideas; he’s just a psycho from some other violent place with other violent people, different from us and our ideals. When it’s revealed he’s actually human, and this planet of death and misery is ours, it makes us reconsider all of our preconceived notions not just about Krall but about our own values as well.

This evil “other” that we could comfortably distance ourselves from was us all along. The threat to the Federation doesn’t come from some unknown boogeyman lurking outside: It comes from within, and from within our own hatred and bigotry — an idea reinforced by the climax of the film, when Krall sneaks into the Yorktown Federation base, sucks the life energy of a human and restores a semblance of humanity to his hideous visage. Elba’s face serves as a reminder that beneath our superficial differences, we are all alike, and that the enemy we so desperately fear is ultimately a lot closer to us than we'd like to imagine.

Revealing Krall’s planet of origin as Earth also makes it clear that Pegg, a British citizen, isn’t just talking about some hypothetical past time, he’s talking about our time and the recent Brexit vote that gripped his home country. Krall’s nativistic views fit all too well in the contemporary political landscape, where potential leaders stir up support by demonizing unions between countries and threaten to divest from them in order to put their own country “first.”

Star Trek Beyond opening the same night Donald Trump accepted the Republican nomination for president may be one of the craziest coincidences in the history of Hollywood releases. Hours after Trump vowed to build a “great border wall” and called his opponent’s desire to allow lawful refugees and immigrants into the United States a symptom of “weakness,” moviegoers could have sat down to watch a Star Trek movie where the villain tells a woman of color who loves a man from another planet and believes in peaceful ideals “Unity is not your strength. It is your weakness.” Krall isn’t Trump, but he sure as hell would have voted for him.

In interviews, Pegg has said these parallels are not accidental. Here’s what he said of Krall to The Daily Beast:

He’s someone who doesn’t believe in togetherness, to give it a more slightly ‘kumbaya’ term. He’s also someone who doesn’t believe that it’s better together. This guy believes that heroes are made in conflict, not in peace, but really it’s just sour grapes. He feels like he got left behind, like he’s been betrayed.

Without ever distracting from Beyond’s ample superficial pleasures, these values come up over and over again in the film. The most moving example might be the very last scene, where Kirk and Spock, who’ve each separately considered retiring from Starfleet service, decide to rededicate themselves to it. The Enterprise that Krall destroyed is rebuilt, and Trek’s iconic Captain’s credo is spoken once more, this time not just by Kirk, but by the entire crew:

“Space, the final frontier. These are the voyages of the Starship Enterprise. Its mission: to explore strange new worlds, to seek out new life and new civilizations, to boldly go where no one has gone before.”

Just about everyone, including plenty of non-Star Trek fans, know these words by heart. As a kid watching the old Star Trek cartoon and The Next Generation on television, they seemed like cool but meaningless words. Spoken at the end of Star Trek Beyond by its entire cast, they felt to me more like a secular prayer for a more hopeful and peaceful future, one that some angry members of society seem determined to prevent from coming to pass.