San Francisco hosted a 25-hour ultra-endurance test last weekend, but it wasn’t a feat of running or physical fitness. It was a test of literary prowess: a nonstop reading of Herman Melville’s infamously challenging and lengthy novel “Moby Dick.”

From noon on Oct. 19 to around 1 p.m. the next day, some 300 people came through the San Francisco Maritime Museum to witness and partake in a collective reading journey involving a notorious whale, an obsessed sea captain and a narrator named Ishmael.

The idea of holding an overnight Melville-athon began in New England, where Massachusetts’ New Bedford Whaling Museum has held a Moby Dick Marathon every year since 1997. The whale-centric event migrated to San Francisco in the 1990s, and began returning more regularly starting in 2015, says Gina Bardi, reference librarian at the San Francisco Maritime Museum and one of the Bay Area event organizers.

Sponsored by the San Francisco Maritime National Park Association, the event is held on a weekend as close to Oct. 19 as possible to commemorate the night in 1860 that Melville visited San Francisco and dined with Jesse Fremont at Fort Mason.

It’s Bardi’s favorite museum event, she says, because it draws a wide community to celebrate a book — one she thinks is beautiful, even if there are haters out there who resisted the read in high school.

“’Moby Dick’ is the great American novel, I think. It’s definitely the great American maritime novel,” she says. “It is challenging, but once you immerse yourself in the language, you realize how special it is. It’s funny. It’s poignant. It’s a history lesson. It’s everything, all in one.”

Nicole Odell, artistic director at San Francisco sketch comedy company Killing My Lobster, says she first participated in the event about five years ago. She quickly came to appreciate the marathon literary and theatrical production and the fact that it is held inside a historical museum, an Art Deco building that looks — appropriately — like a ship.

“It’s probably no secret that a lot of cultural institutions are suffering in San Francisco,” she says. “My hope is that this will continue to spark curiosity in people.”

In the early hours of the marathon, book lovers and whale devotees listened appreciatively, as people took turns at the lectern reading a chapter they’d signed up to read or perform aloud. Some came in costume — one wore a hand-knit orca beanie and a graphic T-shirt emblazoned with the words “Call me.” Others dressed as seagoing tars, burlesque Navy girls and a chaplain.

Every time the performance is held, Bardi says, the event gets bigger. This year’s iteration included a 24-hour crochet circle led by park ranger Noemesha Williams, who plans to transform the resulting yarn crafts into a community quilt, as well as an array of performances by people eager to bring pizzazz to their allotted chapters.

Typically, Bardi says, the attendance starts strong — during the first couple of hours of this year’s marathon, the room held more than 50 attendees. As the hours progress, people tend to trickle out, then return in waves.

During the 2 to 5 a.m. stretch, the crowd typically dies down to only the most die-hard attendees. But even the wee hours of this year’s marathon featured a “good audience,” Bardi says, with readers and listeners alike rewarded by the spectacle of sunrise through the windows of the museum.

By mid-morning, fans were surging back, eager to get in for the finale and the destruction of — no spoilers!

San Francisco resident Joe Murphy, who read one of the novel’s 135 chapters aloud, says it took him three years to read the novel for the first time. In the process, though, he fell in love with it.

“It’s the greatest book and yet completely insufferable,” he says. “It’s been haunting me ever since.”

Looking to get your maritime fix before the next Moby Dick marathon? The Maritime Museum is open from 10 a.m. to 4 p.m. Wednesday to Sunday at Aquatic Park Cove and hosts monthly sea chantey sessions. The next is set for 11 a.m. Nov. 16.