The protagonist is Bob Arctor, member of a household of drug users, who is also living a parallel life as Agent Fred, an undercover police agent assigned to spy on Arctor's household. Arctor/Fred shields his identity from those in the drug subculture and from the police. (The requirement that narcotics agents remain anonymous, to avoid collusion and other forms of corruption, becomes a critical plot point late in the book.) While posing as a drug user, Arctor becomes addicted to "Substance D" (also referred to as "Slow Death", "Death" or "D"), a powerful psychoactive drug. A conflict is Arctor's love for Donna, a drug dealer, through whom he intends to identify high-level dealers of Substance D.
When performing his work as an undercover agent, Arctor goes by the name "Fred" and wears a "scramble suit" that conceals his identity from other officers. Then he is able to sit in a police facility and observe his roommates through "scanners," audio-visual surveillance devices that are placed throughout the house. Arctor's use of the drug causes the two hemispheres of his brain to function independently or "compete". When Arctor sees himself in the videos saved by the scanners, he does not realize that it is him. Through a series of drug and psychological tests, Arctor's superiors at work discover that his addiction has made him incapable of performing his job as a narcotics agent. They do not know his identity because he wears the scramble suit, but when his police supervisor suggests to him that he might be Bob Arctor, he is confused and thinks it cannot be possible.
Donna takes Arctor to "New-Path", a rehabilitation clinic, just as Arctor begins to experience the symptoms of Substance D withdrawal. It is revealed that Donna has been a narcotics agent all along, working as part of a police operation to infiltrate New-Path and determine its funding source. Without his knowledge, Arctor has been selected to penetrate the organization. As part of the rehab program, Arctor is renamed "Bruce" and forced to participate in cruel group-dynamic games, intended to break the will of the patients.
The story ends with Bruce working at a New-Path farming commune, where he is suffering from a serious neurocognitive deficit, after withdrawing from Substance D. Although considered by his handlers to be nothing more than a walking shell of a man, "Bruce" manages to spot rows of blue flowers growing hidden among rows of corn and realizes that the blue flowers are Mors ontologica, the source of Substance D. The book ends with Bruce hiding a flower in his shoe to give to his "friends"—undercover police agents posing as recovering addicts at the Los Angeles New-Path facility—on Thanksgiving.
A Scanner Darkly is a fictionalized account of real events, based on Dick's experiences in the 1970s drug culture. Dick said in an interview, "Everything in A Scanner Darkly I actually saw."
Between mid-1970 (when his fourth wife Nancy left him) and mid-1972, Dick lived semi-communally with a rotating group of mostly teenage drug users at his home in Marin County, described in a letter as being located at 707 Hacienda Way, Santa Venetia. Dick explained, "[M]y wife Nancy left me in 1970 ... I got mixed up with a lot of street people, just to have somebody to fill the house. She left me with a four-bedroom, two-bathroom house and nobody living in it but me. So I just filled it with street people and I got mixed up with a lot of people who were into drugs."
During this period, the author ceased writing completely and became fully dependent upon amphetamines, which he had been using intermittently for many years. "I did take amphetamines for years in order to be able to — I was able to produce 68 final pages of copy a day," Dick said.
The character of Donna was inspired by an older teenager who became associated with Dick sometime in 1970; though they never became lovers, the woman was his principal female companion until early 1972, when Dick left for Canada to deliver a speech to a Vancouver science fiction convention. This speech, "The Android and the Human", served as the basis for many of the recurring themes and motifs in the ensuing novel. Another turning point in this timeframe for Dick is the alleged burglary of his home and theft of his papers.
After delivering "The Android and the Human", Dick became a participant in X-Kalay (a Canadian Synanon-type recovery program), effortlessly convincing program caseworkers that he was nursing a heroin addiction to do so. Dick's recovery program participation was portrayed in the posthumously released book The Dark Haired Girl (a collection of letters and journals from this period, most of a romantic nature). It was at X-Kalay, while doing publicity for the facility, that he devised the notion of rehab centers being used to secretly harvest drugs (thus inspiring the book's New-Path clinics).
In the afterword Dick dedicates the book to those of his friends — he includes himself — who suffered debilitation or death as a result of their drug use. Mirroring the epilogue are the involuntary goodbyes that occur throughout the story — the constant turnover and burn-out of young people that lived with Dick during those years. In the afterword, he states that the novel is about "some people who were punished entirely too much for what they did", and that "drug misuse is not a disease, it is a decision, like the decision to move out in front of a moving car".
A Scanner Darkly was one of the few Dick novels to gestate over a long period of time. By February 1973, in an effort to prove that the effects of his amphetamine usage were merely psychosomatic, the newly clean-and-sober author had already prepared a full outline. A first draft was in development by March. This labor was soon supplanted by a new family and the completion of Flow My Tears, The Policeman Said (left unfinished in 1970), which was finally released in 1974 and received the prestigious John W. Campbell Award. Additional preoccupations were the alleged mystical experiences of early 1974 that would eventually serve as a basis for VALIS and the Exegesis journal, a screenplay for an unproduced film adaptation of 1969's Ubik, an occasional lecture, and the Roger Zelazny collaboration Deus Irae.
Because of its semi-autobiographical nature, some of A Scanner Darkly was torturous to write. Tessa Dick, Philip's wife at the time, once stated that she often found her husband weeping as the sun rose after a night-long writing session. Tessa has given interviews stating that "when he was with me, he wrote A Scanner Darkly [in] under two weeks. But we spent three years rewriting it" and that she was "pretty involved in his writing process [for A Scanner Darkly]". Tessa stated in a later interview that she "participated in the writing of A Scanner Darkly" and said that she "consider[s] [her]self the silent co-author". Philip wrote a contract giving Tessa half of all the rights to the novel, which stated that Tessa "participated to a great extent in writing the outline and novel A Scanner Darkly with me, and I owe her one half of all income derived from it".
There was also the challenge of transmuting the events into "science fiction", as Dick felt that he could not sell a mainstream novel. Providing invaluable aid in this field was Judy-Lynn del Rey, head of Ballantine Books' SF division, which had optioned the book. Del Rey suggested the timeline change to 1994 and helped to emphasize the more futuristic elements of the novel, such as the "scramble suit" employed by Fred (which, incidentally, emerged from one of the mystical experiences). Yet much of the dialogue spoken by the characters used hippie slang, dating the events of the novel to their "true" time-frame of 1970–72.
Upon its publication in 1977, A Scanner Darkly was hailed by ALA Booklist as "his best yet!" Brian Aldiss lauded it as "the best book of the year", while Robert Silverberg praised the novel as "a masterpiece of sorts, full of demonic intensity", but concluded that "it happens also not to be a very successful novel... a failure, but a stunning failure". Spider Robinson panned the novel as "sometimes fascinating, sometimes hilarious, [but] usually deadly boring". Sales were typical for the SF genre in America, but hardcover editions were issued in Europe, where all of Dick's works were warmly received. It was nominated for neither the Nebula nor the Hugo Award but was awarded the British version (the BSFA) in 1978 and the French equivalent (Graouilly d'Or) upon its publication there in 1979. It also was nominated for the Campbell Award in 1978 and placed sixth in the annual Locus poll.
The title of the novel refers to the Biblical phrase "Through a glass, darkly", from the King James Version of 1 Corinthians 13. Passages from Johann Wolfgang von Goethe's play Faust are also referred to throughout the novel.
The rotoscoped film A Scanner Darkly was authorized by Dick's estate. It was released in July 2006 and stars Keanu Reeves as Fred/Bob Arctor and Winona Ryder as Donna. Rory Cochrane, Robert Downey, Jr., and Woody Harrelson co-star as Arctor's drugged-out housemates and friends. The film was directed by Richard Linklater.
An unabridged audiobook version, read by Paul Giamatti, was released in 2006 by Random House Audio to coincide with the release of the film adaptation. It runs approximately 9.5 hours over eight compact discs. This version is a tie-in, using the film's poster as cover art.