Last night, a humid, drizzly evening in Brooklyn Heights, the old-fashioned streetlights near the courthouses made storybook reflections on the sidewalks. Blocks away, below the towering, vaulted ceilings of St. Ann’s and the Holy Trinity Church, Patti Smith, carrying a teacup and a pair of reading glasses, walked up to a microphone, opened a slim little silver book, and began to read aloud from the final published words of her good friend Sam Shepard: “Sometimes, very often, he speaks to himself,” she said, in her familiar accent, the clear, gritty voice of a worker and poet, habitually dropping her g’s—“runnin’, rainin’.” She read on: “Somethin’ for sure’s gonna happen.”

It was a beautifully unwieldy prospect of an evening—a book launch in a Gothic setting, for Shepard’s last work, A Spy of the First Person, itself resolutely hard to categorize, posthumously published this week. Shepard, who won the Pulitzer Prize for Buried Child, is best remembered for the 55 plays he wrote, for his acting and directing career in film, but he was always a writer of “tales,” too, as many of his books have been described. Since Motel Chronicles and Cruising Paradise, his searing, itinerant, and refreshingly genre-defying narrative works have meandered between short fiction and memoir, poem, diary, and myth, drifting in time and territory between Badlands truck stops, border towns, roadside motels, desert ranches, and beyond, heading ever westward. Evocative and unflinching, A Spy of the First Person completes that drift, as its unnamed narrator knowingly approaches his own death, drawn in memory to past lives, subsumed by the rapid shifts in the worlds around him, and, in a spirited and raucous final scene under a full moon, lovingly propelled toward his crossing over.

Last night was a lot like that, too. The evening, orchestrated by PEN America and Shepard’s longtime publisher Knopf, was also a performance by Smith and her band, in celebration of the author, who oversaw the last edits on the book just days before he died in July, of complications from Lou Gehrig’s disease. As his condition worsened, unable to write longhand or on a typewriter, Shepard had begun recording his writing and then dictating it to his family. In a tribute earlier this year, Smith described her own role in helping Shepard shape the final form of the book: “Going over a passage describing the Western landscape, he suddenly looked up and said, ‘I’m sorry I can’t take you there.’ I just smiled, for somehow he had already done just that. Without a word, eyes closed, we tramped through the American desert that rolled out a carpet of many colors—saffron dust, then russet, even the color of green glass, golden greens, and then, suddenly, an almost inhuman blue.”

“There’s nothing more wondrous for a writer than to work with another writer. You see the mechanism, the choices their mind makes,” she said last night to an audience who filled the pews and peered over the edges of the balconies. Ever cool and striking, she wore lace-up combat boots; jeans; a black vest and jacket, likely by another longtime friend Ann Demeulemeester; a T-shirt that seemed to bear splotches of black ink. Her long silver hair occasionally reflected the light of the chandeliers. And later, of Shepard: “We were friends for more than half a century.”

She recounted, as the night went on, how she’d first met him, in 1970 at the Village Gate, where he was playing drums for the Holy Modal Rounders—“this psychedelic hillbilly band,” Smith said. “I thought he was the most awesome hillbilly guy I’d ever seen. I didn’t know he had a sterling reputation.” At the time Shepard, who would go on to win 10 Obie Awards for his plays, more than any other playwright or director, had already won his first four. All of this was unbeknownst to Smith, then a relatively new arrival from South Jersey, tough but still starry-eyed. “I thought he must be a diamond in the rough. I thought I could help him be all he could be! Because we’d just lost Jimi Hendrix and Jim Morrison.”

On one row of pews, people rested their copies of Shepard’s book on a walnut shelf like church hymnals. Alternating between songs of her own and readings from A Spy of the First Person and Shepard’s novel The One Inside (published earlier this year) and her own books Just Kids and M Train, Smith tossed her bookmarks on the floor when she finished reading a passage; by the end of the evening, the Persian rug onstage would be littered with dozens of scraps of paper.

When she sang “Wing”—“And if there’s one thing/ Could do for you/ You’d be a wing / In heaven blue”—she swayed a little, her arms outstretched wide in birdlike wingspan. The song is from her 1996 album, Gone, written after Smith endured some of her keenest losses: Robert Mapplethorpe; her husband, Fred Smith.

Taking a seat on the edge of the stage as her longtime collaborators Lenny Kaye and Tony Shanahan played a rendition of the folk ballad “Bury Me Not on the Lone Prairie”—a cowboy lament for the man with the cowboy mouth—she rocked to its loping rhythm and seemed briefly overcome. Then she caught herself, flashed a warm smile to Shepard’s three grown children, Hannah, Jesse, and Walker, seated in the second row.

“I owe a special debt of gratitude to Sam,” Kaye said later onstage. “You know, he suggested to a young poet living in the Chelsea Hotel that if she wanted to shake up her poetry, she should go talk to that long-haired clerk at Village Oldies,” the erstwhile record store in Greenwich Village. He thanked Shepard then for “your music, your poetry, your plays, and your big, bad self,” and played Elizabeth Cotten’s mortal, soulful country blues song “Freight Train,” slyly swapping in “Bleecker” for the line “Bury me down on Chestnut Street.” As Kaye sang “Please don’t tell what train I’m on,” Smith, on the sidelines, silently mouthed the words.

The somber mood lifted when Smith turned to a section of the book that, she said, had “resulted in hours of hilarity.” She proceeded to read aloud Shepard’s recounting of a scene from the film Point Blank, in which Lee Marvin’s character threatens to backstroke to Alcatraz Island “like it was luxurious to him” and is later pummeled by Angie Dickinson. “This is for Angie,” Smith said, stomping her combat boots on the rug as she launched into “Dancing Barefoot.” Midway through, she fumbled for a lyric. “She—” Smith sang and stopped suddenly, laughing. “What is this, I’ve sung this 9 million times!” It was a moment reminiscent of the prominent pause in her performance last year to accept Bob Dylan’s Nobel Prize on his behalf.

But before the Nobel audience in Sweden, and in Brooklyn last night, the pause comes across not as a mistake but as an acknowledgment of loss, a kind of heart stop, a profound and necessary interruption. “Sam loved it when I did this,” Smith said. “He had this kind of coyote laugh, and so wherever he is, I’m sure he’s laughing now.” She is sublimation, prompted the missing line, and Smith channeled her tough, Angie Dickinson side again, picking up exactly where she’d left off. “It was Sam who taught me about fearlessness onstage,” she said, how there was no such thing as a missed drumbeat. “He taught me the secret of improvisation and it’s gotten me out of thousands of jams in front of thousands of people.”

She read the story of the writing of Cowboy Mouth then, from Just Kids, and played “Beneath the Southern Cross” on Shanahan’s guitar—“obviously,” she said, “a little big for me,” and Shanahan and Kaye sang another cowboy song, Buck Owens’s “Streets of Bakersfield” for the ever-wandering Shepard—it was still, in that room, hard to come to terms with the idea of that restlessness ceasing; the trio covered John Lennon’s “Grow Old With Me,” one of his last songs to Yoko Ono. “Think of it,” Smith suggested, “as one human being to another, a man to his friends. Many of you were his family, his friends.”

The last section Smith read aloud came from The One Inside, a memory of a skinny barefoot kid running with the cattle and a piebald colt in South Dakota. “I feel as strong as I’ll ever be,” Smith read, adding her own emphasis as Shanahan’s piano continued beneath her words, and she segued straight into a cathartic and stirring performance of “Pissing in a River,” from Radio Ethiopia: “Should I pursue a path so twisted? . . . Should I go the length of a river?” Raw and transcendent, it’s a song that seizes power out of sorrow.

Speak in Low Voices, a wooden sign outside the chapel had discreetly admonished parishioners and guests. Now the standing ovation for Smith and her band quickly turned into cacophonous applause, and soon the crowd, more accustomed to a rock show than a Sunday service, began stomping in unison. Do they even allow encores in church? I texted a friend in a faraway pew. Eventually, everyone got the hint and wandered outside, where the night had turned into pouring rain, kicked up on strong gusts of wind. I thought then, too, of something Shepard once wrote about Smith, in a letter to his friend and former father-in-law, Johnny Dark. “She’s had a lot of death in her immediate family but nevertheless still maintains a great bravado about life. One of the things I always liked about her.”