The government faced coughing up more than $10 million to get rid of 10,000 tonnes of hazardous waste from the banks of the Mataura River in Southland.
However, the Tiwai Point aluminium smelter company says it will never ask for the money.
Newly released documents show the company would only agree to store the Mataura waste back at Tiwai Point if the government gave a guarantee, or indemnity, to cover unforeseen costs, such as having to store it for longer than expected if it could not be exported easily.
"NZAS [New Zealand Aluminium Smelters] have advised that they are unwilling to agree to provide the storage services without an indemnity," Treasury told Finance Minister Grant Robertson in January.
"The total maximum value of the indemnity is unknown, however, the total exposure has the potential to exceed $10 million."
There was no dollar cap on the indemnity.
Read the documents released (PDF:580KB)
But the financial risk was less than the risk the waste posed to Mataura, Robertson said.
The pressure had been on the government to speed up the removal of the waste - a processed byproduct of aluminium dross called ouvea premix, which is explosive when mixed with water.
This followed years of wrangling over what to do with it - after the company that bought it from the smelter went bust - culminating in a deal in January for the government to pay half the costs of removal, and the smelter company the other half.
Another risk then emerged: Treasury warned Robertson that "the nature of the proposed [deal] .... [with the Crown meeting half the costs for processing the waste and assuming additional risk through the indemnity] may increase public and stakeholder expectation that the Crown will play a significant role in managing and funding the remediation of the Tiwai Point site".
This risk could be managed by making clear the indemnity and the clean-up were entirely separate, it said.
Officials had already offered the smelter company a multi-million dollar sweetener, if it would in turn agree to spend about $300m on the clean-up when it shuts the plant in 2024.
NZAS rejected the offer, documents show.
Around the same time, a deal over electricity costs was struck to avert a threat that the Rio Tinto-controlled company would close the smelter this year. This deal, in January, followed other power-pricing deals such as one worth $30m in 2013.
The Environment Ministry tried to get out of having to offer an indemnity at all, but could not find anywhere else to store the Mataura waste, which is being trucked back to Tiwai and stored in containers, then exported by Australian processing company Inalco.
Another 10,000 tonnes or so of aluminium dross is also expected to be trucked back to Tiwai from other spots in Southland, where it has been scattered since the 1990s.
Robertson went ahead and approved the Mataura indemnity.
This was on top of two historical indemnities, signed in 2003 and 2004, for the Crown to pay unforeseen costs if dross buried at Tiwai Pt had to be dug up and disposed of.
The Public Finance Act 1989 allows indemnities only where the finance minister thinks it is necessary or in the public interest.
The new indemnity was worth it, Robertson said.
"The longer the material remains at the [Mataura paper] mill, the higher the risk of a pollution event occurring," he said in a statement.
"The indemnity facilitates the expedited removal of waste and helps address the local community's concern.
"While there is a risk to the Crown, the risk is clearly defined and is likely to be smaller than the potential harm caused to the surrounding area and residents from a flooding event."
At any rate, last month, the smelter company agreed to pay all $4m of removal and other costs for the Mataura waste, and not to call on the indemnity.
All the waste was expected to be gone from Mataura by the end of this month, the Gore District Council said.