Star Trek IV: The Voyage Home had been a major box office success upon its release in 1986, but the original crew's thunder had been stolen a little by the launch of Star Trek: The Next Generation a year later. With that series established as a success, Paramount were keen to continue developing the movie series.
In order to retain William Shatner as Captain Kirk, Paramount had made an informal agreement for him to direct the fifth movie in the series. This followed Leonard Nimoy's directing of the third and fourth movies, both of which had been judged highly successful. Shatner's screen directing career was more limited than Nimoy's, limited to ten episodes of his TV series TJ Hooker, but he was certainly familiar with the process as well as knowing his fellow actors well and having the support of the filming crew, which would be a mixture of experienced personnel from the previous movies and staff from Star Trek: The Next Generation. Harve Bennett, who had produced every movie since The Wrath of Khan, also stayed on as producer for this film and helped break the story.
The premise was that the Enterprise crew were going to meet God, something Gene Roddenberry had been pushing for for a long time. However, the twist envisaged by both Shatner and Bennett was that it would be an alien posing as a deity who would manipulate people into following him through faith. Although the premise was judged strong, further rewrites were believed to be necessary to make the story stronger. This turned out to be impossible as the 1988 Writer's Strike took hold, forcing the movie to shoot with a script that had been less revised than was ideal.
Unexpectedly, the shoot turned out to be quite enjoyable. Even those actors who had experienced personal acrimony or issues with Shatner - most famously George Takei - found that Shatner as a director worked quite well. In particular, Shatner enjoyed getting his fellow actors involved in physical activities despite their age (they were then all well into their fifties and James Doohan was approaching his seventies), which they respected. They also appreciated the fact that Shatner kept backstage drama - such as budget cuts and constant interference from the studio - away from the rest of the cast.
As it turned out, Star Trek V: The Final Frontier nearly killed the franchise. The movie opened in the summer of 1989, in a crowded sequel season, playing against Ghostbusters II and Indiana Jones and the Last Crusade as well as Tim Burton's Batman. The film took home $63 million, a franchise low, against a franchise high budget of $33 million. The reviews were also terrible. Shatner accepted the blame, although also pointing out issues such as the script development being cut short by the strike and constant budget cuts meaning they had to use a less experienced special effects company.
Over the next year or so Paramount began to question the future fate of Star Trek on the big screen. The massive burst of popularity that Star Trek: The Next Generation underwent through its third season caused them to change their mind, as this resulted in renewed goodwill to the franchise on the eve of its 25th anniversary. Harve Bennett was asked to develop a new script which would act as a prequel to the series, featuring new, younger actors playing Kirk, Spock and McCoy at Starfleet Academy. This script went through several versions, but as momentum gathered pace the original series actors began to see the benefits of returning in a new film. There was a feeling that they did not want Star Trek V to be their goodbye to the franchise. Bennett was asked to jettison his previous work for a new story involving the old crew but he was not interested in this idea and decided to leave the series after spending ten years working on it.
Paramount began considering new writers and reached out to Leonard Nimoy for ideas. Nimoy went to see Nicholas Meyer, the director of Star Trek II and co-writer of Star Trek IV, and they started throwing concepts around. Meyer was thinking about contemporary issues and suddenly had the thought of the "the wall coming down in space", a reference to the then-recent fall of the Berlin Wall and the resulting end of Communism in Europe. He came up with the story that the Klingon Empire experienced a massive ecological disaster (comparable to Chernobyl) and this sparked the idea of glasnost with the Federation, but forces on both sides working to undermine it, including - unintentionally - Kirk. Nimoy took the idea to Paramount, who immediately saw potential in it, and Nimoy asked Meyer to direct. Nimoy himself was a preferred choice, but Nimoy foresaw possible difficulties with Shatner if Nimoy directed his third Trek movie to Shatner's one. Meyer agreed. Gene Roddenberry was brought on board as a consultant, but fervently disliked the movie's militaristic and naval tone. Meyer described one argument as being extremely passionate and angry, and he later felt ashamed of himself. Meyer particularly took issue with Roddenberry arguing that Saavik (a returning character from Star Trek II and III) would never betray Kirk, as Meyer himself had created the character. Ultimately, actor scheduling issues meant that Saavik had to be removed from the script and replaced with a similar Vulcan character, Valeris.
As with Star Trek V, there were significant struggles over the budget. Eventually, the sixth movie would come in at $27 million, $6 million less than the previous movie. Money was saved by redressing Star Trek: The Next Generation sets wherever possible, as well as reusing the already-built Enterprise, Excelsior and Klingon Bird-of-Prey models, as well as overhauling the Klingon battlecruiser model built for Star Trek: The Motion Picture.
Star Trek VI: The Undiscovered Country was released on 6 December 1991 and was an unexpected hit, grossing just under $100 million. The critical reception was much stronger for the film and some of the marketing for the movie - most notably a guest appearance by Leonard Nimoy as Spock on a Star Trek: The Next Generation two-part episode called Unification - was highly praised. Amusingly, the only real scorn was reserved for the movie's opening special effect in which a massive explosion in space only propagates in two dimensions rather than three. Enough of a fuss was made about this by fans that a similar stellar explosion in the following movie was explicitly shown to be a sphere.
Gene Roddenberry passed away barely six weeks before the film opened. The movie was dedicated to him. In addition, the castmembers' signatures appeared at the end of the film as they expressly said goodbye to the characters they had been portraying for a quarter of a century. The movie marked the final appearances by Nichelle Nichols (to date) and DeForest Kelley in a Star Trek production.
Behind the scenes, Paramount were very happy with the movie's rate of return versus its budget and began planning a seventh film. Star Trek: The Next Generation was planned to end with its sixth season and it was decided to bring the new cast and crew to the big screen. When it was decided to expand this to seven seasons, Paramount declined to change the release date for the movie, forcing the crew to begin development of the film whilst work on the final season of the TV show was underway (everyone involved later admitted that this was a mistake). The seventh movie would feature Walter Koenig and James Doohan in brief cameos, with William Shatner taking a larger role in a story which would teamed him up with Patrick Stewart's Jean-Luc Picard to defeat a mutual enemy.