Richard Selzer in 1977. The surgeon began penning essays and fiction in his 40s and had his literary breakthrough in 1976. (Gerald Martineau/The Washington Post)

Richard Selzer, a surgeon who turned to writing midway through his career, composing essays, memoirs and fiction that explored the mysteries of the human body and the fragile balance between life and death, died June 15 in North Branford, Conn. He was 87.

The death was confirmed by his wife, Janet Selzer, who said the precise cause was not yet determined.

Dr. Selzer, who spent much of his medical career in New Haven, Conn., where he also taught at the Yale University medical school, was inspired to go into medicine by his father, a doctor who died when his son was 12.

Over time, Dr. Selzer was driven by an impulse to find deeper meaning in medicine, a field he described as “at once murderous, painful, healing and full of love.”

He was in his 40s when he began to write essays and fiction, following a rich tradition of writer-physicians that includes Anton Chekhov, William Carlos Williams, Lewis Thomas, Oliver Sacks and his Yale colleague Sherwin B. Nuland.

Dr. Selzer in 1998. (Janet Selzer/Family Photo)

After publishing a collection of short stories, Dr. Selzer had his literary breakthrough in 1976 with “Mortal Lessons: Notes on the Art of Surgery.” His essays about surgery and the organs of the body were sometimes graceful and sometimes grisly and brought readers inside the operating room for a view of the physician’s world seldom seen before.

Dr. Selzer became fascinated by the human and spiritual elements of medicine, including suffering, sorrow and death. “A doctor walks in and out of a dozen short stories a day,” he wrote in a 1988 essay, “The Pen and the Scalpel.”

In later books, including “Confessions of a Knife” (1979), “Letters to a Young Doctor” (1982) and “Taking the World in for Repairs” (1986), Dr. Selzer confronted the moral questions often facing physicians. His books became popular among other doctors and were included in the coursework at many medical schools.

Few writers before Dr. Selzer described the surgical theater with such skill and empathy — including the emotional toll of watching patients die on the operating table. In one essay in “Confessions of a Knife,” he recalled amputating the leg of a man who had once been a professional wrestler. Dr. Selzer realized that, as a boy, he had attended one of the wrestler’s matches with an uncle. During the surgery, a memory came back of his uncle shouting, “Tear off a leg. Throw it up here.”

“And I think that forty years later,” Dr. Selzer wrote, “I am making the catch.”

“Selzer is not for the squeamish — and that is a large part of his achievement,” Newsweek journalist Elizabeth Peer wrote in 1979. “He forces us to look at what is fearsome and disgusting through his own inventive optic, to view human decay as invested with sensuality, irony, bathos, low comedy and high terror. By dwelling on the mechanics of death, he celebrates life.”

Dr. Selzer fully recognized the authority that physicians exercised, including decisions regarding life and death. But in “Letters to a Young Doctor,” he advised a more humble approach.

“You are in service to your patients,” he wrote, “and a servant should know his place.”

Allen Richard Selzer was born June 24, 1928, in Troy, N.Y. Young “Dickie,” as he was known, often accompanied his father on house calls, but he was also drawn to the arts through the influence of his mother, a singer.

When his father died of a heart attack, “it was then and there that I gave myself to medicine the way a monk gives himself to God,” Dr. Selzer wrote in his 1992 memoir, “Down From Troy.” “Not to have done so would have seemed an act of filial impiety. Since I could not find him in the flesh, I would find him in the work he did.”

He received a bachelor’s degree in 1948 from Union College in Schenectady, N.Y., then graduated from New York’s Albany Medical College in 1953. After an internship at Yale, he served in the Army Medical Corps in Korea, where he became seriously ill with malaria. He later returned to Connecticut to teach and to open a surgical practice. (His partner was Bernie S. Siegel, author of the 1986 bestseller “Love, Medicine & Miracles.”)

In his youth, Dr. Selzer was a voracious reader and fascinated by language. After turning 40, he began to write short stories, publishing his first in Ellery Queen’s Mystery Magazine in 1971. Several stories were collected in his first book, “Rituals of Surgery,” in 1973.

He also published essays on medicine in Esquire magazine and received a National Magazine Award in 1975. He gave up his medical practice in 1984 to write full time.

In 1991, Dr. Selzer contracted Legionnaires’ disease and spent 23 days in a coma and was declared dead by one doctor before making a slow recovery. He chronicled his life as a patient in the 1993 book “Raising the Dead.”

In addition to more than a dozen books, he wrote two plays. Another play, David Rabe’s “A Question of Mercy,” about a doctor treating a patient dying of AIDS, is based on a story by Dr. Selzer.

A new collection, “Blood and Ink: A Richard Selzer Reader,” is scheduled for release by the University of Delaware Press in the coming months.

Survivors include his wife of 61 years, Janet White Selzer of North Branford; three children, Jonathan Selzer of Cheshire, Conn., Lawrence Selzer of Winchester, Va., and Gretchen Lehman of Fort Myers, Fla.; and seven grandchildren.

“It is trust, not gratitude or worship, that animates the physician,” Dr. Selzer wrote in “Down From Troy.” “To palm a fevered brow, to feel a thin wavering pulse at the wrist, to draw down a pale lower lid — these simple acts cause a doctor’s heart to expand. . . . Add to this the possibility of the grace of healing, and there is no human contact more beautiful.”