This June, the Environmental Protection Agency began work to clean up the long-abandoned Red and Bonita mine in Silverton, Colorado — a mine that had been leaking toxic metals into the Animas River for years.

Then everything went horribly, horribly wrong.

On August 5, EPA contractors were assessing leaks from the nearby Gold King mine, abandoned since 1923, when they inadvertently shook loose a debris dam that had been holding back a massive amount of water laced with arsenic, lead, and other toxins.

All that contaminated water gushed out, unstoppably, coursing down the mountains and turning the Animas River a sickening shade of yellow. Here's a picture from August 6:

At first, the EPA said that about 1 million gallons of wastewater had been released. Then, on an August 9 press call, officials said they'd taken fresh measurements and actually 3 million gallons had spilled out — about five Olympic-size swimming pools' worth.

Officials have warned people in the region to avoid contact with the river as the contaminated water pulses through. The EPA is also warning people with wells in nearby floodplains to have their water tested before drinking or bathing. Both the nearby city of Durango and La Plata County in Colorado have declared states of emergencies, as has the Navajo Nation Commission on Emergency Management.

This whole fiasco raises a couple of key questions: Why was the EPA messing around with abandoned mines in this area? And how did the agency manage to trigger such a massive spill? To understand this story, we have to walk back through the legacy of mining in the West, which is still creating environmental problems to this day.

Colorado has hundreds of old mines still leaking toxins

In the 1870s, miners first came to the Silverton region to seek out gold, silver, and other valuable metals — as they did throughout the West. But as Stephanie Ogburn at KUNC and Jonathan Thompson at High Country News explain, that mining boom left a serious mess behind.

There were two major environmental problems associated with mining. First, up until the 1930s or so, miners often just dumped their tailings — waste material that frequently contained toxic heavy metals — into nearby streams and rivers. Around Silverton, heavy metals accumulated in the riverbeds of the Upper Animas River, and their effects lingered for decades. For many years, fish disappeared from these waters.

Second, as miners dug and blasted shafts, they'd typically encounter groundwater. As that water mixed with air and sulfides, it would react to form sulfuric acid. That acidic wash, in turn, dissolved and picked up various heavy metals in the earth, including zinc, cadmium, arsenic, lead, and copper. This toxic stew is known as "acid mine drainage," and it's still a problem to this day, flowing out of mines and into nearby streams.

The last mine near Silverton closed in 1991. But there are still more than 400 abandoned mines in the region, and many continue to fill up with toxin-laced water from rain and snowmelt that then drains out into rivers and streams. And cleaning up these old mines has been a gruesome challenge for decades.

Colorado has struggled to clean up these old mines — and EPA recently stepped in

That brings us to the particular Red and Bonita and Gold King mines that the EPA was working on. These, too, have a tangled history.

In 1991, Sunnyside Gold Corp. closed its last big mine in the region, American Tunnel. After long negotiations with the state, Sunnyside began cleanup efforts and eventually plugged American Tunnel in three places to prevent further toxins from leaking out.

Unfortunately, the water in the mines then backed up and found an outlet elsewhere. In 2006, acid drainage began leaking out of the nearby Red and Bonita mines, which had long been abandoned. The company that had taken ownership of these mines in the meantime, Gold King, soon ran into financial difficulties and could no longer treat the water that was pouring into the Upper Animas River. After a brief period when fish had returned, the Animas was poisoned yet again.

Now enter the EPA. Ever since the 1980s, the agency has wanted to declare parts of the Silverton region a Superfund site, which would trigger federal funds for intensive cleanup efforts. But local residents have long resisted this move, out of concern that the bad publicity would drive away tourists.

So instead, the EPA has been taking a more piecemeal approach — working with the state and the Animas River Stakeholder Group to clean up mines in the region bit by bit. In this particular case, that meant removing waste from both the Red and Bonita and nearby Gold King mines, diverting water that was entering those mines, and eventually plugging their openings with concrete bulkheads. The cost of this project? Some $1.5 million.

It's worth noting that even this cleanup measure was always considered highly uncertain. EPA workers didn't know if the acid mine discharge would eventually back out and flow somewhere else. "This, in a way, is as much as experiment as the American Tunnel," Steve Fearn, co-coordinator of the Animas River Stakeholders Group, told the Durango Herald in June.

The cleanup efforts went horribly awry in August

The EPA began cleanup work on the Red and Bonita mine in late June 2015. On August 4, workers were clearing out the partially collapsed Gold King mine when they breached a debris dam that had been holding back toxic water, filled with contaminants. That water flowed out, and the Animas River was suddenly flooded yet again by a gusher of heavy metals.

Some notes here: First, the river was hardly pristine before this incident, and it's unclear how much additional damage this blowout has actually caused. Testing by the EPA has revealed that the heavy metal contaminants became more diluted by the time the water reached the town of Durango, and early tests downstream with fish cages have revealed that the water isn't as toxic as initially feared. Still, it's a worrisome situation, and the agency is scrambling to monitor things closely.

Meanwhile, this isn't even the first disastrous blowout from an old mine. Jonathan Thompson offers some further context: "In June of 1975, a huge tailings pile on the banks of the Animas River northeast of Silverton was breached, dumping tens of thousands of gallons of water, along with 50,000 tons of heavy-metal-loaded tailings into the Animas. For 100 miles downstream, the river 'looked like aluminum paint,' according to a Durango Herald reporter at the time; fish placed in a cage in the water in Durango all died within 24 hours."

Still, what's eye-catching here is that this time the EPA is at fault — not a mining company. Even though the agency was trying to clean up a toxic mess that has been simmering for decades, even though efforts to stem the flow of polluted mining water have often gone awry because it's an inherently difficult task, there's an undeniable irony in this whole debacle.

"It’s hard being on the other side of this, in terms of being the one who caused this incident," David Ostrander, the EPA’s head of emergency management, told a crowd in Durango, according to the Guardian. "We usually respond to emergencies, we don’t cause them," he said.

The agency is currently facing criticism for failing to notify other agencies quickly enough after the spill occurred — including the state of New Mexico, where the polluted water is heading. Indeed, if a company had acted in a similar fashion, the EPA might have potentially levied fines or other penalties.

In the meantime, the polluted water is coursing down the river, eventually joining up with other waterways and making its way into New Mexico, with the long-term effects still unknown.

Further reading:

-- Note that Silverton isn't the only region in the West with a legacy of mining pollution. Nicholas Riccardi reports for the AP that there are between 40,000 to 55,000 abandoned mines from California to Idaho, and states have struggled to clean them up for decades. Also: "The federal government says 40 percent of the headwaters of Western waterways have been contaminated from mine runoff."

-- The Denver Post has been delivering frequent updates on the Animas situation.

-- I mentioned them above, but this great KUNC piece by Stephanie Ogburn on the EPA's cleanup efforts in Silverton is definitely worth your time. So is this excellent piece by Jonathan Thompson of High Country News.