On April 17, 1961, the great and the good of the American film industry gathered at the Civic Auditorium in Santa Monica for their annual ceremony of mutual backslapping. This had been the year of Psycho and Elmer Gantry; of Spartacus and The Magnificent Seven. None of these films, however, picked up any major Oscars. Instead, one film made a clean sweep, and one man – Billy Wilder – became the first individual to walk away with three of the most prestigious awards: best director, best original screenplay (with his co-writer IAL Diamond) and best picture. The film in question was The Apartment.

As Wilder was being presented with the screenplay award by the playwright Moss Hart, legend has it that Hart whispered some words into his ear: “This is the moment to stop, Billy.” Wilder, however, was seen to smile and shake his head. He was in his mid-fifties, his directing career was at its peak, and he had no intention of quitting at this point.

Jack Lemmon and Shirley MacLaine with Wilder at the United Artists Studio commissary during the filming of The Apartment, which would sweep the Oscars for best director, best picture, and best original screenplay in 1961.

Twenty-seven years earlier he had arrived in Hollywood — like so many of his generation — as a penniless refugee from Nazi Germany. “People describe my films as pessimistic,” he would say to an interviewer at the height of his fame. “But let me remind you, it was the optimists who ended up in the death camps, and the pessimists who now have swimming pools in Beverly Hills.” Born in 1906 in the village of Sucha Beskidzka — then part of Austria-Hungary — he had spent his schooldays in Vienna, before moving to Berlin where he began making his living as a journalist. Wilder’s roots, then, placed him in Vienna at the height of its interwar artistic ferment, and then at the cultural epicenter of Weimar Germany. It’s hard to imagine an artist’s formative influences being more thoroughly European.

Wilder moved seamlessly from journalism to screenwriting — Berlin’s UFA Studios then being the powerhouse of the European film industry — but the rise of Hitler soon made it impossible for him to stay in Germany. At first he fled to Paris, where he lived for one year at the Hotel Ansonia, the famous hangout of so many Jewish refugees from the Nazis. But then he sold a script to Hollywood and was offered a one-way passage to the States on the SS Aquitania. He spent the voyage reading detective novels in English in order to acquire some basics in a language of which he still spoke barely a word.

“But let me remind you, it was the optimists who ended up in the death camps, and the pessimists who now have swimming pools in Beverly Hills.”

That sense of deficiency in a language in which he was now expected to write never left Wilder. He retained a strong Austrian accent for the rest of his life and never wrote a screenplay in Hollywood by himself: partly because he enjoyed the creative sparks that came with collaboration, but also because he could never trust himself to use American idioms with confidence.

The first of his collaborators was Charles Brackett, an old-school, pipe-smoking Republican who was the polar opposite of the volatile, irreverent, left-leaning Wilder. Throughout the 1930s and early 1940s they wrote many successful scripts together, specializing in light comedy with the occasional darker, more acerbic undertone that can usually be ascribed to Wilder’s mordant sense of humor. One of their biggest hits, Ninotchka, may be a frivolous rom-com at heart, but there is still a moment when Greta Garbo, as a Soviet envoy visiting Paris, can deliver this chilling report on events back home: “The last mass trials were a great success. There are going to be fewer but better Russians.”

Wilder and his most trusted screenwriting partner, “Iz” Diamond, seduced Hollywood with Some Like It Hot and The Apartment.

Soon enough, annoyed by the way directors were treating his scripts, Wilder turned to direction himself, and his third feature, the classic film noir Double Indemnity (co-written not with Brackett but with Raymond Chandler) was a big success, paving the way for the Oscar-winning triumph of The Lost Weekend in 1946, and then, four years later, Sunset Boulevard. The latter is a film that would be in most people’s top three of Wilder masterpieces, even though it is, in some ways, a fractured, double-headed piece of work: telling the story of a silent movie star (Gloria Swanson) who lives in gothic isolation waiting to be rediscovered by a Hollywood that has long since moved on, it aims to be both a satire on the film industry’s ruthless mores and a tragic melodrama about a woman who cannot come to terms with the aging process. (Swanson, by the way, turned a mere 50 the day after shooting began.) But somehow Wilder, with the chutzpah of a man whose career had started to gather irresistible momentum, pulled the combination off. His laconic self-confidence was such that, when the cameraman asked him how he envisioned the scene where Swanson arranges a macabre burial service for her pet chimp, Wilder is said to have replied: “Oh, you know — just your usual monkey funeral shot.”

Wilder’s close-up with Sunset Boulevard star Gloria Swanson in 1950.

After Sunset Boulevard, Wilder and Brackett parted company, and for a few years Wilder searched in vain for another regular co-writer. Brackett had grown weary, among other things, of his colleague’s sharp tongue, and this continued to be a sticking point. George Axelrod, arriving in Wilder’s office to begin work on the adaptation of his own Broadway hit The Seven Year Itch, made the mistake of bringing a copy of the play with him. “Excellent,” Wilder said, relieving him of the bulky manuscript. “We can use this as a doorstop.”

In 1957, however, Wilder found the man who was to become his closest and most trusted collaborator: a quiet, mild-mannered, Romanian-born writer called IAL (Iz) Diamond, who combined a ruefully comic outlook on life with a calm and professional approach to screenwriting. While their first effort together, Love in the Afternoon, never really took off, their second struck gold. It was a remake of a recent German comedy, Fanfaren Der Liebe, about two impoverished jazz musicians who dress up as women to get work. Wilder and Diamond relocated the action to Prohibition-era Chicago, cast Tony Curtis, Jack Lemmon and Marilyn Monroe, and presented the world with Some Like It Hot, one of cinema’s most purely joyous comedies, in which not a scene or a line is wasted.

Wilder directed Marilyn Monroe, Lemmon, and Tony Curtis in the cross-dressing comedy Some Like It Hot.

The Apartment, Wilder’s third film with Iz, had a more acrid, more serious tone, while still containing some sublime moments of comedy and an undercurrent of romanticism and tenderness that was new to Wilder’s work. Here, at last, he had found a collaborator with the same sense of humor, who shared his dedication to the craft of screenwriting, who understood his strengths and weaknesses and complemented them perfectly. Why on earth would he listen to anyone who told him that “this is the moment to stop”?

And yet — did history prove Moss Hart right? Wilder and Diamond made nine more films together. There are great films among them — some of Wilder’s finest, in my view – but none are among his best-remembered works. Irma La Douce may have been one of his biggest box-office successes, but few people cherish it now. One, Two, Three may be one of the fastest, sharpest comedies of all time, but it never inspired the affection of Some Like It Hot. Kiss Me, Stupid, with Dean Martin sending himself up as the lecherous “Dino Martini”, may have foreshadowed the trend of celebrities playing unflattering caricatures of themselves (Wilder was so often ahead of his time), but its sexual politics leave a sour taste.

The Private Life of Sherlock Holmes flopped in 1970, but later inspired the Benedict Cumberbatch series Sherlock.

And then there was the Sherlock Holmes film. Wilder spent more than a decade bringing his vision of the great detective’s thwarted love life to the screen. He took over Pinewood for six months, spent more than $10 million, and then The Private Life of Sherlock Holmes flopped, big time: the studio made him cut it down by almost an hour before they would even release it. In the last few years the Beatles had arrived, the Summer of Love had happened, Bonnie and Clyde and Easy Rider had changed American cinema. Suddenly the Wilder/Diamond, classical approach to film-making looked fusty and dated.

On its release in 1970 The Private Life of Sherlock Holmes was at best ignored, at worst derided by many critics and film-makers. But when it started airing on British television a few years later, it met with a different response from an even younger generation. Mark Gatiss and Steven Moffat saw it and, decades later, cited it as their main inspiration for Sherlock. I saw it and fell in love with its strange combination of comedy and aching melancholy. It was the first Billy Wilder film I had seen, and it remains my favorite. Ever since then, I’ve wanted to write a book about Billy Wilder.

In the 1970s, Hollywood, crazy for Taxi Driver and The Deer Hunter, refused to finance Wilder’s Fedora, which featured a cameo by Henry Fonda as himself.

That book turned out to be not the essay I was envisaging, but a novel, which zooms in on Wilder, aged 70, preparing for his last-but-one film, Fedora. I chose this moment not because failure is more interesting than success (Fedora is a faltering attempt to revisit the world of Sunset Boulevard), but because I’m interested in how tastes change and trends come and go, and the later career of Billy Wilder illustrates the problems faced by any artist who has to negotiate this. In the film world the problem is especially acute, because unless you can raise a large sum of money you’re literally prevented from expressing yourself at all. The first humiliation Wilder faced with Fedora was that no Hollywood studio would finance it: suddenly he had to face up to the fact that, a decade and a half after sitting on top of the world with The Apartment, he had become unbankable.

He eventually raised the money for Fedora from Germany, a country with which he had a love-hate relationship: the country that had nurtured him, culturally, but was also the site of the death camps where many of his family — including his beloved mother — had perished. He shot the film in European studios and locations, with Iz Diamond always by his side, but predictably enough, in a Hollywood that was by now fired up by Taxi Driver, Close Encounters and The Deer Hunter, the finished product disappeared, leaving scarcely a ripple. Wilder made one more film after that, then called it a day, moving over to make way for the younger generation, cherishing vague hopes of making a film of Schindler’s Ark, but graciously acknowledging, when he saw Steven Spielberg’s version, that he could not have done it any better himself. He died in 2002, outliving Iz by 14 years, but never attempting to write another screenplay after his cherished colleague’s premature death.

Wilder won a $50 bet with producer Leland Hayward when he rode the wing of a barnstorming biplane over Costa Mesa, California, during the filming of The Spirit of St. Louis.

Wilder’s career reminds us that a director’s later, less sure-footed films can finally reveal themselves as being among their most moving and interesting. And the fate of Fedora might serve to remind artists in every medium of this difficult truth: that there comes a moment when you have to recognise that your time in the spotlight is over. May we all handle that moment as well as Billy Wilder did.

Jonathan Coe is a novelist. His latest book, Mr Wilder and Me, is out now