WATCH: A drone’s view of the Calaveras Dam.

Click here if you are having trouble viewing the gallery or video on a mobile device.

SUNOL — After toiling away in the remote hills east of Interstate 680 on the Alameda-Santa Clara county line for seven years, hundreds of construction workers have finally finished the largest dam built in the Bay Area in 20 years.

The 220-foot tall dam at Calaveras Reservoir — as high as the roadway on the Golden Gate Bridge soars above San Francisco Bay — replaces a dam of the same size, built in 1925. State dam inspectors flagged the older dam in 2001 as at risk of collapse in a major earthquake on the nearby Calaveras Fault. If it had failed, state officials estimated it could have sent a 30-foot wall of water into Fremont and neighboring communities, potentially killing thousands of people.

The new dam, a tightly compacted earth-and-rock structure a quarter-mile wide at its base, can withstand a 7.25 magnitude quake on the Calaveras Fault, engineers say.

“The improvements are 100-fold over the old dam. We expect this one to be here for another 100 years,” said Dan Wade, director of water capital projects for the San Francisco Public Utilities Commission, which owns the reservoir.

The new dam is the tallest such structure built in the Bay Area since Los Vaqueros Reservoir in Contra Costa County was completed in 1998. It is an important part of the Hetch Hetchy water system, which provides drinking water to 2.7 million people in Alameda, Santa Clara, San Mateo and San Francisco counties.

The project also represents the final piece of a wider, $4.8 billion effort, ordered by the state legislature in 2002, to harden the Hetch Hetchy water system in the Bay Area against earthquakes. That project involved upgrading drinking water treatment plants, replacing pipelines and even boring a massive tunnel under San Francisco Bay to replace a rickety series of leaking metal pipes that once brought water from the East Bay to the Peninsula.

The new dam was an engineering headache, however, beset by delays and cost overruns.

In 2009, the project was expected to cost $409 million and be completed in 2015. Now the cost is $823 million. The final pieces, including paving seven miles of nearby roads and installing electrical equipment and sensors in the dam, are expected to be finished by the spring of 2019, more than three years late.

The reason for the delays? Once they started digging, construction workers found two ancient landslides in the 20 million-year-old geologic layer cake nearby, forcing them to carve away millions of tons of rock and sediment to better anchor the new dam on more solid footing. They also had to shore up hillsides more than expected, and were delayed three months during the flooding winter of 2016-17.

“Despite all the challenges, we’ve come a long way,” said senior project manager Susan Hou. “I feel good. It’s been a long journey.”

Outside experts say the delays were an unfortunate, but unavoidable, reality.

“They didn’t do anything wrong,” said Nicole Sandkulla, a civil engineer and CEO of the Bay Area Water Supply and Conservation Agency, an organization of 26 cities and water districts from Daly City to Hayward that purchase Hetch Hetchy water from San Francisco.

“It’s like home remodeling. When you buy an old home, the walls all look sound,” she said. “But when you go to replace the windows, you realize you have dry rot. But you still have to fix it.”

Most Bay Area residents know that Hetch Hetchy water comes from Hetch Hetchy Reservoir in Yosemite National Park. But that pristine snow melt provides only 85 percent of the system’s water. The rest comes from five Bay Area reservoirs, of which Calaveras is the largest.

When full, Calaveras holds 96,850 acre-feet — about 31 billion gallons — enough for roughly half a million people’s needs a year.

After state inspectors found earthquake risks, they ordered Calaveras Reservoir to be lowered to no more than 40 percent full. The reservoir is 25 percent full now. When winter rains start, it will begin to fill again.

“If we have a wet winter, it can fill in one year,” Wade said. “But it could take four years. Or if we’re in a drought, it could take longer.”

In a state with a growing population where water is always short, some have wondered why San Francisco wouldn’t enlarge Calaveras Reservoir, since it was replacing the dam anyway. Sandkulla’s group, which represents two-thirds of Hetch Hetchy customers, and whose water bills were tripled to pay for for the seismic upgrades, wanted a larger reservoir.

Sandkulla said San Francisco officials chose the status quo size because they worried about lawsuits and the difficulty of getting permits from state and federal agencies.

Wade noted that the clay core and other features of the new dam will allow it to be raised 150 feet some day, if future generations decide, which would quadruple the reservoir’s size. He said San Francisco officials decided against doing that as part of this dam project because the only way to fill such a large reservoir would have been to pipe in water, requiring a costly re-engineering of the whole system, rather than relying on water from nearby creeks flowing off Mount Hamilton and the Diablo Range, the way it is now.

Related Articles The nearly 500 Californians killed in 1928 dam disaster might finally get a memorial

Oroville Dam: Bill to form citizens advisory commission signed into law

Map: Bay Area major earthquakes and fault lines Jeff Miller, executive director of the Alameda Creek Alliance, an environmental group, said 68 environmental groups signed a letter in 2005 telling the San Francisco Public Utilities Commission it needed to help bring back endangered steelhead trout, and if it didn’t, it would face lawsuits. In the end, San Francisco agreed to build a fish ladder on the Alameda Creek Diversion Dam nearby, and not expand the reservoir, he said.

The project also gained attention after the roughly 300 workers began digging up huge teeth from Megalodon sharks 20 million years ago, along with hippo teeth, fossilized palm trees and whale skulls. They all were donated to the UC Berkeley Museum of Paleontology.

Before San Francisco was required to upgrade the Hetch Hetchy system, studies showed a major quake could cut off water for 60 days, causing significant health problems and fire risks. Now, the system is strong enough so that 70 percent of customers will have water within 24 hours after the Big One.

“It’s a huge deal,” said Sandkulla. “This dam represents a significant increase in reliability for all the customers. It is a major investment in local storage, which is really important in droughts and seismic events.”