“Star Trek Beyond,” the 13th film in the fabled sci-fi series and the third since J.J. Abrams rebooted the franchise and sent it into a parallel time line, opens July 22, 966 days into the crew’s “five-year mission” — 9/66 being the month and year that the original TV series debuted on NBC, where it would survive only three seasons.

Fifty years later, of course, the mission continues, with something of a cult following.

“To say ‘something of a cult following’ is the biggest understatement in history,” said actor Simon Pegg, who plays the ship’s longtime engineer, Scotty, and also co-wrote the screenplay for the film. “It has the cult following.”

And this is both good and bad. For “Star Trek Beyond,” Justin Lin (“True Detective,” “Fast & Furious”) took the helm from now-producer Abrams, who was busy directing “Star Wars: The Force Awakens.” It was a messy takeoff.

“It was not easy logistically,” Lin said from London. ‘But I knew what I was signing up for. I’d prefer to start from nothing, and build this movie together.”

His chief collaborators were Pegg and co-writer Doug Jung, who were given the unenviable task of devising a new screenplay in just a few months for one of the best-known movie franchises.

advertisement | advertise on newsday

“It was horrifying,” Pegg said, not exactly kidding. A script by Robert Orci, who had co-written the two previous Abrams-directed “Star Treks,” was being eighty-sixed by the producers. “The decision to not shoot the script they had, that they were developing and had spent money on, came quite late and it was in January of 2015 that we began working on a blank page. And shooting was in June.

“But it wasn’t something I could say no to,” Pegg added. “I knew I would regret it if I said no, even though it felt like an insurmountable task.”

They were never shown the Orci script, he said. “They said ‘It’s better that you don’t see it,’ and we were like ‘OK.’ I think maybe they didn’t want us to go down a similar track.”

The film was not ready to be screened at the time of this writing, according to Paramount, but the story apparently involves the crew of the USS Enterprise facing insurmountable odds, an unstoppable alien force and unspeakably bleak prospects; somehow, one suspects, things may work out. But one of the bigger questions for “Star Trek” fans is how faithful the movie will be to their favorite franchise’s mythologies, philosophies and characters.

“It’s the same as when I signed on to do ‘Fast and Furious,’ ” said Lin. “It’s about respect. We’re at the 50th anniversary and I wanted to capture the essence of what made ‘Star Trek’ great. You have to accept the mission statement” — which, as fans know, is “to explore strange new worlds, to seek out new life and new civilizations, to boldly go where no man has gone before.”

“That’s what exploration and discovery are all about,” Lin said.

One of the more exploratory innovations of “Star Trek Beyond” involves the sexuality of helmsman Sulu, originally played by George Takei, now a noted gay activist, and portrayed in the last three films by John Cho (of “Harold & Kumar” fame). Sulu, a la the script by Pegg and Jung, is apparently gay, something to which Takei has taken exception. His logic seems to be that if the ‘Star Trek’ universe is so open and accepting, why has Sulu been in the closet for 50 years?

Cho and Takei have met, and Cho said his Sulu predecessor was “gracious as hell.”

advertisement | advertise on newsday

“At the time, I was concerned that his character was supposedly Japanese and had a Japanese name and I wondered if it would ruffle feathers,” said Cho, who is of Korean descent. Takei is Japanese-American. “But he was cool and said [“Star Trek” creator Gene] Roddenberry was adamant that the name denoted the [Sulu] sea, which borders several Asian countries and that it represented no one nation. It was anti-nationalist, as is the concept of the show.”

Lin is among the more successful young Asian filmmakers in Hollywood. (“It’s sort of the entirety of the dream,” said Cho, “having [Asian] people in front of the camera and behind it.”) He’s also encountered some tragic circumstances: Paul Walker, the star of Lin’s “Fast & Furious 6,” died a few months after that film’s release; Anton Yelchin, who portrays Chekov in ‘Star Trek Beyond,” died in an accident June 19.

“I’m still processing it now,” Lin said, “but I feel very privileged to have worked with him, even on just one film. Sometimes in this business there’s a lot of pettiness and politics, but he always showed up with a smile on his face. And he had a thousand ideas. And he reminded me that we’re making movies — you should care about that. His attitude will live on, for sure, with me.”