The idea for the film began when Buñuel was working as an assistant director for Jean Epstein in France. Buñuel told Dalí at a restaurant one day about a dream in which a cloud sliced the moon in half "like a razor blade slicing through an eye". Dalí responded that he'd dreamed about a hand crawling with ants. Excitedly, Buñuel declared: "There's the film, let's go and make it.'"They were fascinated by what the psyche could create, and decided to write a script based on the concept of suppressed human emotions.
In deliberate contrast to the approach taken by Jean Epstein and his peers, which was to never leave anything in their work to chance, with every aesthetic decision having a rational explanation and fitting clearly into the whole, Buñuel made clear throughout his writings that, between Dalí and himself, the only rule for the writing of the script was: "No idea or image that might lend itself to a rational explanation of any kind would be accepted." He also stated: "Nothing, in the film, symbolizes anything. The only method of investigation of the symbols would be, perhaps, psychoanalysis.