It was one of the most risque passages in European fiction when it was published in 1925, and still flushed cheeks when Nicole Kidman and Tom Cruise starred in Stanley Kubrick’s adaptation at the turn of the millennium.

Arthur Schnitzler. Photograph: hulton-deutch collection/corbis

Arthur Schnitzler’s Traumnovelle (Dream Story) tells the story of a Viennese doctor who attends an orgiastic masked ball, confesses his transgression to his wife the next day but is forgiven – and, in Kubrick’s Eyes Wide Shut - even rewarded with a tryst.

Now, however, British academics have discovered that the original version of the Austrian author’s story had an alternative ending, in which the doctor is punished for betraying his wife. Researchers based at Cambridge University have found that the famous orgy scene was contained in a draft for Schnitzler’s Das weite Land, a tragicomedy later adapted by Tom Stoppard as Undiscovered Country but originally written in 1908 – about 17 years before Dream Story was published.

Set around the turn of the 20th century, the published version of the story features a young doctor called Fridolin and his wife, Albertine, whose sexual fantasies belie their bourgeois existence. One evening, after Albertine has confessed her attraction to a young man she had seen while on holiday, Fridolin bumps into an old university friend in a coffeehouse. He obtains the secret password to a clandestine masked ball, where he has a seductive encounter with a beautiful stranger.

He confesses his adventure to his wife the next morning, but Albertine tells him not to worry too much about the future. The well-known version of the story ends with the couple greeting the new day with their daughter.

Kubrick’s version added a more explicit touch to the final scene, with Kidman telling Cruise: “There’s something we need to do as soon as possible.” When Cruise asks what she means, she responds: “Fuck.”

In the newly discovered original draft, however, the outcome is less harmonious, with the wife putting her foot down: “He confesses his adventure to her. She chases him away.”

The original sketch is also less ambiguous about the nature of the doctor’s transgression: whereas Fridolin in Dream Story watches the orgy but resists the temptation to take part, the original draft suggests that he actually commits adultery. And while Fridolin embarks on his adventure while his wife is asleep, his earlier incarnation visits the ball while believing his wife to be on her deathbed.

The new findings will be of no small interest to Schnitzler’s biographers: the author read a draft of Das weite Land to his wife Olga on her sickbed. A notorious womaniser in his younger years, Schnitzler later found himself at the receiving end of romantic infidelity. Olga’s affair with the composer Wilhelm Gross is said to have been the final straw for an already frail relationship and they separated.

Revered as one of the leading figures of Vienna Modernism, Schnitzler was regarded by Sigmund Freud as his personal doppelganger, because they shared an interest in the hidden meaning of dreams. Outside the German-speaking world, he is best known for his play Reigen, which has inspired a number of cinematic and theatrical adaptations, including Max Ophüls’s La Ronde and David Hare’s Blue Room.

The UK researchers are working alongside teams from Germany and Austria in the first systematic deciphering of the notes for Schnitzler’s literary works. The archival holdings in Cambridge University library amount to some 40,000 sheets, and the work of transcription and edition will take many years.

The fact that the sketch of the orgy scene had previously gone unnoticed can mainly be attributed to the fact that the author had trained as a practitioner at Vienna’s General hospital and jotted down his thoughts with the proverbial “doctor’s handwriting”. Notes vary between something approaching modern handwriting, with idiosyncratic features, and German Kurrent, based on medieval cursive writing.

According to Andrew Webber, principal investigator on the project, there are only a “small handful of people on the globe who can read Schnitzler’s handwriting with any authority”. The researchers say they plan to upload some of the more cryptic pages from the archive to the internet and invite the public to try to decipher his writing.

The papers are held in Cambridge thanks to an adventurous rescue just a few weeks after Austria’s Anschluss with Nazi Germany in March 1938, seven years after Schnitzler died of a brain haemorrhage.

The writer’s works had been dismissed by Nazi authorities as “Jewish filth”. Fearing the destruction of his archive, Olga Schnitzler approached a 23-year-old Cambridge graduate who happened to be in the Austrian capital and asked for the university’s help in saving the papers. A British seal was put on the doors of Schnitzler’s study and the works were spared from the Nazi book burnings.