Director and screenwriter Ingmar Bergman was inspired to make the film after talking to a clergyman, who related how he had offered spiritual advice to a fisherman who later killed himself. To this, Bergman added the ideas of the clergyman struggling with his faith and a relationship outside marriage. The idea of the character becoming depressed over fear of China and weapons of mass destruction was based on an article Bergman himself had read, and he acknowledged it reflected his own dread.