... Star Trek V is the epitome of my career, my experiences, my hopes and dreams. It is the quintessential me.
William Shanter on The Final Frontier,1989
During the 1966–69 Star Trek television series, Shatner and Nimoy's lawyers drafted what Shatner termed a "favored nations clause", with the result that whatever Shatner received — e.g., a pay raise or script control — Nimoy also got and vice versa. Nimoy had directed Star Trek III: The Search for Spock and Star Trek IV: The Voyage Home. Shatner had previously directed plays and television episodes; when he signed on for The Voyage Home following a pay dispute, Shatner was promised he could direct the next film.
Shatner conceived his idea for the film's story before he was officially given the director's job. His inspiration was televangelists; "They [the televangelists] were repulsive, strangely horrifying, and yet I became absolutely fascinated," he recalled. Shatner was intrigued that not only did these personalities convince others God was speaking directly to them, but they became wealthy by what Shatner considered false messages. The televangelists formed the basis for the character "Zar", later "Sybok". Shatner's first outline was titled "An Act of Love", and many of its elements — the Yosemite vacation, the abduction of Klingon, human and Romulan hostages on the failed paradise planet — survived to the final film. In Shatner's early draft, Kirk is overwhelmed by Zar's superior numbers of followers and Spock, McCoy and the rest of the Enterprise crew come to believe in Zar's divinity. Kirk feigns acceptance of Zar's beliefs to travel with him to the God planet, which to Shatner would be a desolate, fiery waste. When Kirk confronts "God", the image of the being transforms into that of Satan, and Kirk, Spock, and McCoy split up in their escape. Kirk eludes capture but goes back to save his friends from being carried away to Hell.
Shatner had presented his idea to studio head Frank Mancuso while filming The Voyage Home. Mancuso liked Shatner's idea and agreed to hire a writer to draft a film treatment. Shatner wanted novelist Eric Van Lustbader, but negotiations between Lustbader and Paramount failed over the author's requested $1 million salary. Shatner dictated the story himself and gave it to Paramount's production president Ned Tanen for input.
Producer Harve Bennett was exhausted by his work on the previous three Star Trek films and wanted to move on, feeling that he was not part of the "Star Trek" family and that he had been mistreated by Nimoy. When Shatner tried to convince Bennett to reconsider, the producer insisted on a meeting at his home. After several hours of discussion Bennett agreed to return. Bennett disagreed with several elements of Shatner's story, feeling that because no one could assuredly answer the question of God's existence, the ending of the film would never be satisfying. Bennett also told Shatner that the film had the feeling of a tone poem rather than an adventure story. The studio agreed with Bennett, reasoning that the subject matter could be too weighty or offensive to theatergoers.
Shatner and Bennett began reworking the story. Concerned that knowing the renegade Sybok's motivation from the beginning of the story was anticlimactic, the team moved the revelation to later in the story. Shatner said that Bennett also suggested turning the God entity into an "evil alien pretending to be God for his own gain". Having satisfied themselves and Paramount with the adjustments, Shatner and Bennett approached Star Trek II: The Wrath of Khan writer and director Nicholas Meyer to pen the script, but he was unavailable. Bennett found a script by David Loughery and showed his work to Shatner, who agreed that he would be a good fit for the task of scripting Star Trek.
Not everyone was happy with the story. Star Trek creator Gene Roddenberry objected to the characters' search for God in general, and more particularly, the idea of a God as portrayed by Western religion. One of Roddenberry's employees suggested some of his employer's animosity towards the story stemmed back to Star Trek: The Motion Picture. Roddenberry had wanted to approach that film with similar ideas that investigated the nature of God but was rejected by Paramount. Roddenberry, Nimoy and Kelley all disagreed that Spock and McCoy would betray Kirk, which Loughery explained was done to give a conflict in which "one man stands alone" from the rest.
Loughery stopped work on the script when the Writers Guild of America went on strike, and the production was further delayed when Nimoy began working on another project.During this time, Shatner reconsidered elements of the Star Trek V story; he made Sybok's character softer and more sympathetic. When the writers' strike ended Loughery returned to work on the script while Shatner flew to the Himalayas for a job. When he returned, he felt betrayed by Loughery's revisions, which he felt transformed the search for God into the search for the mythical paradise Sha Ka Ree — a word play on "Sean Connery", whom they wanted for Sybok's role. Though Shatner convinced Bennett and Loughery to revise much of the script, Sha Ka Ree remained; it was changed to a place of ultimate knowledge of which Sybok had received visions. The script was also rewritten to address Nimoy and Kelley's concerns.
While Roddenberry, Kelley and Nimoy gave their approval to the revised script, Paramount was concerned that the film would go over-budget as written and ordered cuts. Shatner's envisioned angels and demons at the film's climax were converted to rock monsters that the false god would animate from the earth. Shatner wanted six of the creatures, but was forced to accept just one. Concerned that the franchise's momentum following The Voyage Home had disappeared, Paramount rushed the film into production in late 1988 despite the writers' strike cutting into pre-production.