Odds are that most San Franciscans have never even heard of the Lake Merced Tunnel, but it’s a historic piece of 19th century infrastructure that’s critical to keeping the city’s sewers flowing without dumping filth straight into the Pacific Ocean.

It’s also in danger of being destroyed by that same ocean, as climate change sends the tides creeping ever inward, forcing the city to embark on a $150 million-plus preservation plan.

According to the San Francisco Public Utilities Commission (SFPUC), the Lake Merced Tunnel is a 14-foot wide drainage pipe that runs underneath the Great Highway and serves the Oceanside Treatment Plant and related pumping station on Ocean Beach.

The plant is one of three in SF responsible for sanitizing both stormwater and sewer discharges before dumping them, and handles about 20 percent of the city’s wastewater.

When there’s too much waste for the plant to take in all at once, like during big storms, the overflow goes into the Lake Merced Tunnel.

While being a giant sewer pipe may not sound very impressive, when it was built in 1896, the San Francisco Call hailed the tunnel as “one of the most difficult pieces of engineering work ever undertaken in the state” and gushed about its completion in just 17 months despite “many difficulties encountered in eddies of subterranean water.” (Note that the tunnel predates the treatment plant by nearly 100 years; the Oceanside facility wasn’t built until 1993, adapting the existing tunnel for its purposes.)

The tunnel was one of the crowning achievements of what you might call a sewer century in San Francisco.

“Back in the 1800s we built more sewers than anyone,” George Engel, an operations manager at the SF Public Utilities Commission, tells Curbed SF.

“We still have in the order of 100 miles of sewers” from the 19th century in operation in San Francisco today, Engels adds, tunnel included.

The Lake Merced Tunnel, like the entire apparatus that disposes of SF’s waste, is a bit of a hidden gem. In 2014 SPUR marveled at the “invisible infrastructure” that keeps the system moving but also out of sight of the beach-going public.

But this obscure bit of plumbing is important—and it’s also in serious danger. The Planning Department warns that erosion and sea level rise threaten to swamp the tunnel and related infrastructure in the near future.

The city has not in so many words said that the coastal water plant itself is in danger—SFist describes the facility as potentially being “flushed into the Pacific”—but there is important plumbing infrastructure inland of the tunnel, and it is plausible to imagine more elaborate problems in the future.

To counter this aquatic encroachment, the city has a $151.3 million plan to pushback the ocean.

Related Trump administration says SF homeless camp feces violates the Clean Water Act

In a November memo SFPUC General Manager Harlan Kelly laid out the two critical initiatives: removing several thousand feet of the Great Highway between Sloat and Skyline Boulevard (a stretch that is doomed to be eaten away), and creating a “multipurpose coastal protection/restoration/access system.”

That last one is a broad term consisting of actions ranging from “managed retreat” of the shoreline to “beach nourishment”—i.e., carting in vast amounts of sand to replace eroded material (something the city already does every year).

The city hopes to begin actual construction work in 2023.

As the San Francisco Examiner notes, the current price tag has swelled some $60 million compared to previous estimates. The city blames “refinements” in the construction plan for increasing costs.

In 2015, environmental group Surfrider advised that the city consider relocating the Lake Merced Tunnel altogether, arguing that since “sea level rise and climate change‐driven storms are due to intensify in the years ahead” that keeping the tunnel where it is only delays the inevitable, but SFPUC will nevertheless move forward trying to preserve the tunnel at its original location.