Gérard Brach surrounded by the posters of his movies... Photograph: Sergio Gaudenti/Kipa/Corbis

When the Polish would-be director Roman Polanski met the French would-be screenwriter Gérard Brach in 1959, it was the beginning of a beautiful friendship. They shared a love of surrealism, a pessimistic view of life and an absurdist humour that is evident in the 10 films they made together.

At the time, Brach, who has died of cancer aged 79, was 32 years old and a discontented press officer with 20th Century Fox. He was introduced to Polanski in Lodz, where the latter had just completed five years at the Polish state film school, during which time he had made several shorts, heavily influenced by Samuel Beckett and the Theatre of the Absurd. In his 20s, Brach had given up his own studies after developing tuberculosis, and spent five years in a sanatorium. There he met the Dadaist poet Benjamin Péret, who later introduced him to André Breton, author of the Surrealist Manifesto.

Under their influence, Brach drew a series of designs based on Songs of Maldoror by the perverse 19th-century poet Lautréamont, whom the surrealists adopted as a precursor of their movement. Brach took his designs to a left bank gallery in Paris, and it somehow managed to lose them. In order to make ends meet he worked for 20th Century Fox - until he decided to give it all up when Polanski moved to Paris in 1963. They first co-wrote an episode for the inconsequential four-part feature The Beautiful Swindlers (1963); entitled A River of Diamonds, it was directed by Polanski. Then came a black comedy, Do You Like Women? (1964), the only feature directed by Jean Léon.

At the same time, Brach and Polanski wrote the script for When Katelbach Comes (later retitled Cul-de-Sac), for which they were unable to get financial backing until three years later, after the international success of Repulsion (1965). The first of four films Polanski shot in England, Repulsion was a psychological drama of the mental breakdown of a young woman (Catherine Deneuve) culminating in murder. According to Brach, her problem derived from her fear of sexuality or sexual disgust, a strong element in the Brach-Polanski films.

Cul-de-Sac (1966) had echoes of Waiting for Godot, but was more directly influenced by Harold Pinter, not only in the casting of Donald Pleasence, who had triumphed in Pinter's The Caretaker a few years previously, but also in the portrayal of sexual humiliation and in the relationship of the two gangsters. However, the depiction of a married couple's sexual tensions that erupt into violence when an outsider intrudes on their world was a favourite theme developed in the Polanski-Brach screenplays, one which the Polish director had already dealt with in his first feature, A Knife in the Water (1962).

In the same year, Brach worked on Claude Berri's touching and amusing The Two of Us (Le Vieil Homme et l'Enfant, 1966), about an anti-semitic old man (Michel Simon) who fosters a Jewish boy during the war. After co-writing Polanski's stylish and witty horror film parody, The Fearless Vampire Killers (1967), the pair parted company for a while when Polanski went to the United States to make Rosemary's Baby (1968). In the interim, Brach directed two films, La Maison (1970) and Le Bateau sur l'Herbe (1971), both about male characters whose lives are changed by the intrusion of a woman.

What? (1973), the next film written with Polanski, had a similar theme, but was more fragmented and stylised. Described as "an Alice in Wonderland of sexual perversions" derived from Brach and Polanski's "momentary desires", it was a spectacular flop. More successful, but just as personal, was The Tenant (1976), a film that more than most deserves the overused epithet Kafkaesque. Apart from Bitter Moon (1992), their last collaboration, which dealt with a group of sado-masochistic characters so beloved of the director and scriptwriter, Tess (1979), Pirates (1985) and Frantic (1988) trod on safer ground.

Throughout their partnership, Brach did most of the writing. "We talk and then he writes it," Polanski explained. "Then he comes back into the room and we change it together."

Besides his work with Polanski, Brach co-wrote screenplays for several of the most notable films of the 1980s, mostly for non-French directors: Identification of a Woman (Michelangelo Antonioni, 1982), Favourites of the Moon (Otar Iosseliani, 1984) and Maria's Lovers (1984) and Shy People (1987), both by Andrei Konchalovsky. Nevertheless, his most acclaimed screenplays were for Frenchmen: Berri, the two-part Marcel Pagnol adaptation, Jean de Florette and Manon des Sources (1986); and Jean-Jacques Annaud, The Name of the Rose (1986), The Bear (1988), The Lover (1992) and Minor, currently being shot in Spain.

Brach was agoraphobic, and for almost the last 10 years he hardly ever left the Paris apartment where he lived alone, rarely receiving visitors, except for the occasional director.

· Gérard Brach, screenwriter, born July 23 1927; died September 9 2006