In praising his 1963 novel, “John Goldfarb, Please Come Home!,” a Cold War spoof that Mr. Blatty later adapted for the screen, Martin Levin of The New York Times invoked the humorist S. J. Perelman, one of Mr. Blatty’s literary idols; Mr. Blatty, he said, “writes like Perelman run amuck.”
The phenomenal success of “The Exorcist” essentially signaled the end of Mr. Blatty’s comedy career, making him for all practical purposes the foremost writer in a new hybrid genre: theological horror. It was a mantle he was never entirely comfortable wearing.
When he declined his publisher’s entreaties for a sequel to “The Exorcist” and instead delivered an elegiac memoir about his mother, “I’ll Tell Them I Remember You,” published in 1973, Mr. Blatty felt the first cinch of the horror-writing straitjacket.
“My publisher took it because I wanted to do it,” he was quoted as saying in “Faces of Fear” (1985), a collection of interviews with horror writers by Douglas E. Winter. “But the bookstores were really hostile.”
“The sad truth is that nobody wants me to write comedy,” he said in another interview. “ ‘The Exorcist’ not only ended that career; it expunged all memory of its existence.”
Mr. Blatty gave various accounts of what led him to try his hand at horror. He sometimes said the market for his comedy had waned in the late 1960s, and he was ready to move on. At other times, he said that his mother’s sudden death in 1967 had led to a renewed commitment to his Roman Catholic faith, and to a soul searching about life’s ultimate questions, including the presence of evil in the world.
In every account, he said the idea for “The Exorcist” was planted in 1949, when he was a student at the Jesuit-affiliated Georgetown University in Washington and read an account in The Washington Post of an exorcism under the headline “Priest Frees Mt. Rainier Boy Reported Held in Devil’s Grip.”
The incident, widely discussed at the time among Georgetown students and faculty members, came back to Mr. Blatty 20 years later as the basis for a book about something not getting much press in the fractured, murky landscape of late-1960s America: the battle between Good and Evil.
He began writing what he thought would be a modest-selling thriller about a girl, a demon and a pair of Catholic priests.
About halfway through, he later said, he sensed he had something more. “I knew it was going to be a success,” he told People magazine. “I couldn’t wait to finish it and become famous.”
William Peter Blatty was born on Jan. 7, 1928, in Manhattan to Peter and Mary Blatty, immigrants from Lebanon. His father left home when he was 6, and his mother supported the two of them by selling quince jelly on the streets, yielding a wobbly income that precipitated 28 changes of address during a childhood he once described as “comfortably destitute.”
The church figured prominently in his life. His mother was a churchgoing Catholic, and he was educated at prominent Jesuit-run schools that admitted him on full scholarships: the Brooklyn Preparatory School, now closed, where he was the 1946 class valedictorian, and Georgetown, from which he graduated in 1950.
After serving in the Air Force, Mr. Blatty worked for the United States Information Agency in Beirut. He returned to the United States for a public relations job in Los Angeles, where he hoped to begin his career as a writer.
He had already published his first book — a memoir, “Which Way to Mecca, Jack?” — but was still working in public relations in 1961 when he appeared as a contestant on “You Bet Your Life,” the television quiz show hosted by Groucho Marx. He and a fellow contestant won $10,000.
His winnings freed him to quit his day job and become a full-time writer. He never had a regular job again.
Mr. Blatty lived in Bethesda. In addition to his wife, the former Julie Witbrodt, whom he married in 1983, he is survived by their son, Paul William Blatty; three daughters, Christine Charles, Mary Joanne Blatty and Jennifer Blatty; and two sons, Michael and William Peter Jr., from earlier marriages; seven grandchildren; and six great-grandchildren. Another son, Peter Vincent Blatty, died in 2006; his death was the subject of Mr. Blatty’s 2015 book, “Finding Peter.”
His work after “The Exorcist” included several more theologically themed works of horror, including “The Ninth Configuration” in 1978 (a reworking of “Twinkle, Twinkle, Killer Kane,” from 1966) — and “Legion” in 1983. Both books were made into movies, directed as well as written by Mr. Blatty; the film version of “Legion” was released in 1990 as “The Exorcist III.”
Mr. Blatty became reconciled over the years to the overwhelming dominance “The Exorcist” — most recently adapted into a 2016 TV mini-series — would have on his reputation as a writer. (He also maintained a sense of humor about it, as reflected in the name of a comic novel about Hollywood he published in 1996: “Demons Five, Exorcists Nothing.”) He knew, he told several interviewers, that it would be what people remembered him for.
But one thing bothered him.
Many moviegoers, including the president of Warner Bros., had interpreted the movie’s climax — in which the younger of the two priests (played by Jason Miller) goads the demon into leaving the girl to take up residence inside him instead, then jumps to his death — as a win for the demon.
That was not how Mr. Blatty meant it. For years he pleaded his case to Mr. Friedkin, a longtime friend. In 2000, Mr. Friedkin relented, issuing a re-edited director’s cut of the film that made the triumph of Good over Evil more explicit.
With the same purpose in mind, Mr. Blatty rewrote parts of the original book, even adding a chapter, for a 40th-anniversary edition of “The Exorcist” published in 2011.
It was essential to him, he told The Times-Picayune of New Orleans in 2000, that people understand the point of “The Exorcist”:
“That God exists and the universe itself will have a happy ending.”
An earlier version of this obituary misidentified the character in the movie “The Exorcist” who jumps to his death. It is the younger of the two priests, played by Jason Miller — not the elder priest, played by Max von Sydow.