In a come-from-behind win for Royal Dutch Shell plc and other oil giants, an appeals court has ruled that the U.S. government must reimburse the companies for the cost of cleaning up a World War II–era toxic dump site in California. The amount of damages remains to be determined, but it could top $100 million.

Reversing a prior ruling, the U.S. Court of Appeals for the Federal Circuit concluded that the government needs to take responsibility for petroleum refinery waste that the oil companies dumped on 22 acres of land in Fullerton, Calif., in the 1940s. The Federal Circuit remanded the case to the trial judge, Thomas Wheeler of the U.S. Court of Federal Claims, to figure out exactly how much reimbursement the oil companies are entitled to for cleanup efforts they undertook in the 1990s.

The ruling is a win for a trio of companies—Shell, Atlantic Richfield Company (ARCO) and Chevron Corp.—which are represented by the appellate boutique Cooper & Kirk. James Kirk of Cooper & Kirk handled the Federal Circuit oral argument, squaring off against Stephen Tosini of the U.S. Department of Justice’s civil division.

As Circuit Judge Evan Wallach explained in great detail in Monday’s majority decision, aviation gas (or “avgas”) was crucial to the U.S. war effort. In a series of agreements from 1942 and 1943, the government agreed to buy massive amounts of avgas from Shell, ARCO and oil companies now owned by Chevron. They dumped waste byproducts from their avgas production in Fullerton, on land now known as the McColl Superfund Site.

Cleaning up McColl became a top priority in 1980 after the passage of the Superfund law, known formally as the Comprehensive Environmental Response, Compensation and Liability Act (CERCLA). In a lawsuit brought under CERCLA, California and the U.S. government won a ruling in 2002 that the oil companies are liable for $100 million in remediation costs.

The defendants brought a breach of contract suit in 2006, alleging that the government should indemnify them for the remediation costs. They pointed to a clause in the 1942 and 1943 agreements in which the government agreed to reimburse the oil companies for future “taxes, fees or charges” relating to avgas production levied by local, state or federal government agencies.

The case has taken years to wind its way through the courts, in large part because the Federal Circuit ruled in 2012 that the original judge, Loren Smith, should have recused himself entirely because his wife owned Chevron stock. Wheeler finally dismissed the case on summary judgment in January 2013, ruling that the “taxes, fees or charges” provision doesn’t put the government on the hook.

The Federal Circuit disagreed in Monday’s ruling. After offering a short but stirring primer in military history, Judge Wallach concluded that the oil companies agreed to supply avgas “in return for the government’s assumption of certain risks outside of the oil companies’ control.” The environmental cleanup costs were one such risk, Wallach concluded.

In a dissenting opinion, Circuit Judge Jimmie Reyna wrote that his colleagues are reading for too much into the “taxes, fees or charges” provision. “The majority errs by interpreting a straightforward ‘taxes’ clause as a catch-all indemnification provision,” he wrote. “The oil companies’ best opportunity to recover their cleanup costs from the government was through the CERCLA litigation in California, and they should not now be allowed to recover by fitting a square peg into a round hole.”

In the majority decision, Wallach wrote that the amount of reimbursement doesn’t lend itself to a summary judgment. Cooper & Kirk’s James Kirk said in an interview that his clients are seeking upward of $100 million in the damages trial.