IN A room in the National Records of Scotland, in Edinburgh’s Princes Street, Margalit Fox held in her gloved hand a crumpled fragment of wrapping paper. It weighed barely an ounce; but it bore a name and a Glasgow address, and that was enough to ensure that it played a key role in one of the gravest miscarriages of justice Scotland has known.

The name and address are that of Oscar Slater, a poor German Jew. Having been pursued by the Glasgow police as far as New York, from where he was extradited in February 1909, he was convicted and sentenced to death three months later for the murder of Marion Gilchrist, a well-to-do recluse of 82.

She and Slater had lived just a few streets apart in the centre of the city. He was entirely innocent of the murder charge but he paid for it dearly. Though his death sentence was commuted to life with hard labour, he would spend 18-and-a-half years in the grim prison at Peterhead.

The Slater story, which has occasionally been referred to as the Scottish Dreyfus affair, has been written about before, of course, but what Fox, an American author and journalist, has done in her new book, Conan Doyle for the Defence, is to focus not only on the intricacies of the case but also on the crucial intervention of Arthur Conan Doyle, the Edinburgh-born creator of Sherlock Holmes. Subjecting the Crown’s case against Slater to the rigorous analysis that was Holmes’s hallmark, Conan Doyle saw it for the unsatisfactory, insubstantial outrage that it plainly was.

The book details the shortcomings uncovered by Conan Doyle and others: judicial and prosecutorial misconduct, witness tampering, the suppression of exculpatory evidence, the subornation of perjury. For Conan Doyle it was a “disgraceful frame-up, in which stupidity and dishonesty played an equal part.”

He brought his attentions to bear on the case on three separate occasions. As Fox observes, the first was in 1912, “when he undertook his original analysis of the murder, investigation and trial”, and by which time the case was, to him, “as brutal and callous a crime as has ever been recorded in those black annals in which the criminologist finds the materials for his study.”

His second involvement was in 1914, when “he agitated for a judicial review of Slater’s conviction (an event that, when it did come to pass, ‘savoured rather of Russian than of Scottish jurisprudence’, as Conan Doyle wrote bitterly).”

What prompted him to get involved for one final time, after a considerable number of years, was a heartfelt personal plea to him written by none other than Slater. In January 1925 he wrote a message on a pellet of paper that was smuggled out beneath the dentures of a fellow prisoner, and then conveyed to Conan Doyle. After a couple of years, writes Fox, Conan Doyle, “after great struggle … won Slater’s freedom and saw his conviction overturned.”

Slater was deeply grateful for the author’s efforts on his behalf, but their relationship ended messily, with Conan Doyle, in his final years, pressing Slater to cover at least some of the costs he had incurred in his long campaign. Slater was disinclined to pay up, even though he had received £6,000 in official compensation, the equivalent of perhaps £336,000 today.

Says Fox, speaking by phone from New York: “When I, toward the end of my research, came across, the file of a court case that said ‘Conan Doyle v Slater’, I was stunned. It’s one of those things you find where you want to go back to your hotel, go to sleep, and hope in the morning that the whole thing has disappeared and that it was just a bad dream. Of course it wasn’t, and I had to deal with it.

“But in a way it gives the case a kind of painful symmetry; the case sprang out of social-class tensions and it ended that way, too, because there is this sort of Pygmalion aspect. Conan Doyle had pulled himself up by his bootstraps and gotten out of the ghetto and made himself into a gentleman, and was later knighted. He could free Slater but he couldn’t make him into a gentleman, no matter how hard he might have wished to.”

Conan Doyle died in 1930, aged 71. Slater, having reverted to his real name, Oscar Leschziner, lived in Ayr, where he died in January 1948, at the age of 76.

Fox is a senior writer at the New York Times, where she has written some 1,400 news obituaries. “My entree into the case goes back thirty years. When I first moved to New York after graduate school, I was in my twenties and working at uninspiring entry-level jobs in book publishing. Taking the subway to work one day, the book I had brought to read was John Dickson Carr’s biography of Conan Doyle, which had been published in 1949.

“Near the end, almost as an aside and in a very casual way, Dickson Carr said that Conan Doyle also played detective in a real-life wrongful conviction for murder. I almost dropped the book in the middle of the train. Sir Arthur Conan Doyle, creator of the world’s most famous detective, had played a real-life detective in a murder case? Why wasn’t this better known?

“I became fascinated but of course I was not a journalist myself then … I was certainly not in a position to do anything further about it. But I filed it away in the back of my brain, in that area that Holmes calls the ‘brain attic’.

“Then, when I finished The Riddle of the Labyrinth, my last book, I was casting about for a new, narrative non-fiction book to write, and I remembered this story.”

The book took her almost six years from start to finish. She flew to Scotland in 2014 and spent a week each at the National Records and Glasgow’s Mitchell Library, “torturing their reprographics departments” with requests for thousands of pages of documents. They arrived at her home several months later, in a dozen large Jiffy bags. It took her some 18 months to go through them.

“I make no claim to have discovered anything, because these are archival documents, there for the taking …but what I am very proud about is that I am the first writer that I am aware of to have really made extensive use of Slater’s prison letters. To me they are remarkable, and so moving. You can see the passage of time in them; you see his loving parents grow old and die, then [Slater’s] sisters start writing, then the sisters’ children start writing. It’s really an index of how long he was in prison.”

As well as having the “disturbing kind of pleasure” of holding that slender scrap of archived wrapping paper, which put the police on Slater’s trail and was subsequently used as Crown evidence against him, Fox also, in 2014 and again last autumn, walked the route between Gilchrist’s home at 49 West Princes Street (“it’s a little bit seedy now”) and Slater’s red-sandstone flat around the corner in St George’s Road (“that’s now a very seedy-looking building.”)

Is there any similarity between researching someone’s life for an authoritative news obituary and researching the century-old story of Oscar Slater?

“I think there is,” she says. “Obituary news articles as they exist in the modern era - certainly in our newsroom - are, at bottom, biographical, narrative non-fiction. Writing a book, as I’ve discovered, particularly with this one, is the same process, just gridded up a thousand times.

“Since we don’t have the onus of daily deadline pressure for book-writing, we have the luxury - and I suppose it’s trading one kind of onus for another - of going through masses and masses of documents, which I did, and recreating, in this case, not a whole life, but unknown segments of a life, both of Sir Arthur and, more particularly, of Slater himself.

“As I write in the introduction,” she continues, “Slater is a cipher in his own story in other treatments.” The book makes the point that most previous books on Slater share what Fox describes as “a certain grassy-knoll aspect, speculating breathlessly on who really did kill … Gilchrist.” (She herself declines to join these authors on the grassy knoll, on the grounds that if it was impossible to identify the real killer in 1909, it is “utterly nonsensical” now.)

Scottish readers will be struck by the sense of injustice that victimised Slater and put him behind bars for so many years, but there is another resonance for Fox herself.

“Little did I think when I started on the book,” she concludes, “how germane the incidents it details, which are about what today we would call racial profiling, are to life in America and elsewhere today.” The book is “about the construction of the ‘evil other’, about framing someone, about running someone out of town and even almost sending someone to the gallows, just because he’s different from you. I can’t think of anything more frighteningly relevant to our time than that.”

***Conan Doyle for the Defence: A Sensational Murder, the Quest for Justice and the World’s Greatest Detective Writer, is published by Profile Books, £16.99