The Mechanics Institute sits in downtown San Francisco near the tangled traffic of Market Street. You might pass by, avoiding the crush of humanity on the sidewalks, and not even notice it: a nine-story neoclassical building that houses the oldest public library on the West Coast of the United States. At 161 years old, the Mechanics’ Institute is a testament to continuity in a city whose most persistent feature is change.

San Francisco’s Mechanics’ Institute was born in 1854, when a group of men marched into the tax collector’s office inside City Hall. These men—mostly builders, artisans, and other “mechanics”—made arrangements for new library with $300 and just four books: a Bible, the US Constitution, a legal resource, and an encyclopedia of architecture. California still had no colleges or universities. San Francisco was a young, masculine city that “grew in almost a day,” as contemporaries put it, on land wrested from Mexico just six years earlier. By 1854, the Gold Rush was winding down. Miners and prospectors who had flooded to San Francisco from around the world, hoping to strike it rich, now scrambled to make a living. “San Francisco is in a state of moral ferment,” wrote a reporter in 1854. “The scum and froth of its strange mixture of peoples, of its many scoundrels, rowdies and great men, loose women, sharpers and few honest folk, are still nearly all that is visible.”

The Mechanics’ Institute opened its doors to the public in 1855, in a single rented room in the center of town. In the beginning, it was a refuge from the rough-and-tumble streets, where out-of-work miners scraped by and vigilantes ruled. The Institute promised enlightenment, and locals responded. In just a few years, its burgeoning book collection and slate of lectures attracted a steady stream of new supporters. These were not the oppressed masses or reformers on a moral mission. Rather, the Institute’s charter members were builders, businessmen, machinists, carpenters, artisans, and others who worked with their hands. This was an age of self-improvement and self-made men, though the library was also popular with women. “Diffusion of knowledge at the least expense to the seeker,” was its motto.

Today the Mechanics’ Institute is enjoying a renaissance. Membership is growing once again, after peaking in 1910 at 10,000. Why is that? The library, still downtown but now at 57 Post Street, has become a preferred destination for writers and freelancers across the Bay Area; an ideal workspace that is easy to reach on public transit. Members of the Institute are writers, thinkers, creators; “mechanics” as Walt Whitman intended. The Institute has counted Eadweard Muybridge, Jack London, Ambrose Bierce, and Gertrude Stein in its ranks. Local legends also appear on the roster: the naturalist John Muir; the blue jeans magnate Levi Strauss; chocolatier Domingo Ghiradelli; and Andrew Hallidie, inventor of the cable car and former president of the library’s board. “We reflect the DNA of San Francisco,” Ralph Lewin, the Executive Director of the Mechanics’ Institute, told me. “The Institute was created by the people who built this city,” he said. “It’s about books, but even more so about community.”

On a recent Friday morning, I watched readers and itinerant workers settle into the library’s beaux-arts reference room, light streaming through high windows. All week the place was a flurry of cultural activity: book discussion groups, film screenings, networking events, even a nighttime tour of the Institute followed by cheese and wine. The library shares the building with the Mechanics’ Institute Chess Club, the oldest organization of its kind in the country. On Tuesday evenings, it becomes one of the city’s most democratic spaces, where a 10 year-old from Mongolia faces off against a middle-aged lawyer from Pacific Heights. Every Thursday morning at 11, the “Philosopher’s Club” gathers in the chess room. For years, it brought together a self-proclaimed Stalinist, a reform communist, a GOP supporter, and a veteran of the NSA, among others, to exchange opinions and ideas. The group recently lost two of its beloved members. There are also newcomers to the community at 57 Post Street: Litquake, San Francisco’s annual literary festival, and Zyzzyva, the venerable magazine of West Coast writing. Both tenants, exiled by the city’s rising rents, found a home at the Mechanics’ Institute, which owns the building.

Can a building be a character in history? The Mechanics’ Institute, a child of the Industrial Revolution, was created by new wealth in a new city that seemed unlikely to succeed. San Francisco’s first bubble, made of gold, was short-lived. The city remained geographically isolated, lawless, and unstable—pretty much destined for failure, according to contemporary accounts. Its workforce came from everywhere and was notoriously unreliable and unskilled. The future of the Mechanics’ Institute was always uncertain; tied to the boom-and-bust cycles of the new industrial economy. But by the last decades of the nineteenth century, it had emerged as one of San Francisco’s most popular gathering places, where locals shared an irrational faith in the city’s future and their own. The 1906 earthquake and fire that devastated the city, virtually erasing its past, also destroyed the Mechanics’ Institute. Its collections languished for three years in makeshift housing. “Many members have told me,” wrote Joseph Cumming, Secretary to the Institute, in 1907, “that of all things they were deprived of, they missed the library the most.” Like the city that lay in ruins, the Mechanics’ Institute was revived. Albert Pissis, the Mexican-born architect, whose legacy is still visible across the city, was recruited to the task of rebuilding. In 1910, the Mechanics’ Institute reopened for business in its current building on 57 Post Street.

“There is a hunger for a sense of community these days,” Lewin told me, “everything is so fragmented.” Change has always been the master narrative of San Francisco. But today’s affordability crisis, triggered by an influx of tech wealth and with it, tens of thousands of new residents, has opened deep divisions between cultures old and new, and what is considered authentic. In this environment, the Mechanics’ Institute is regaining the place it held in the cultural landscape of 1880 or 1900. Once again the Institute is young, egalitarian, and thriving. Most new members, Lewin explained, are under 40, which is hardly the case for other dues-paying organizations around the country. What remains to be seen is whether today’s new wealth, like that of yesterday’s, will reinvest in civic institutions, especially this one, where the future of the past lies. Continuity is a rare commodity these days, community even more so for many San Franciscans. An old institution for mechanics is filling the void.