In a deal said to be worth billions of dollars, Alaska officials have agreed to settle a nearly decade-long dispute over shipping rates with the oil company owners of the trans-Alaska pipeline.

The proposed settlement, which needs regulatory approval, is designed to end an epic battle that has pitted the state, along with Anadarko Petroleum and Tesoro Alaska, against the owners of the trans-Alaska pipeline, primarily BP, ExxonMobil and ConocoPhillips.

"The settlement is historic," said Robin Brena, a private attorney in Anchorage representing Anadarko and Tesoro, companies that ship oil in the 800-mile pipeline but don't own a piece of it.

Sparking the settlement negotiations were decisions two years ago by the Federal Energy Regulatory Commission and the Regulatory Commission of Alaska. The agencies said the pipeline owners could not recover costs of a badly managed upgrade project by charging higher fees to move oil.

The major oil companies sued in state and federal courts, challenging the regulatory decisions, said John Ptacin, chief assistant attorney general for Alaska.

The proposed settlement involves more than 40 rate cases from 2009 to 2015. The state had argued the pipeline shipping rates were too high. Higher rates mean less revenues for Alaska, in the form of royalties and taxes.

Under the terms of the proposed deal, the state can keep $224 million it has already collected, and collect another $165 million, the Department of Law said in a prepared statement Thursday.

The pipeline owners also agreed not to recover $625 million by boosting pipeline shipping rates. That amount stems from capital costs associated with the strategic reconfiguration project that automated and electrified equipment along the pipeline.

The project began in late 2003 but lasted years longer and cost hundreds of millions dollars more than anticipated. The errors included a lack of scrutiny on project details, FERC said.

Because those capital costs can't be recovered in shipping rates, Alaska can count on higher royalty and tax revenues, Ptacin said.

"It is in our view a victory for the state," he said of the settlement.

The settlement will keep future rates lower, the statement from Law Department said.

Taking into account future benefits, the long-term value of the deal is in the billions of dollars, Brena said.

Before the settlement is final, approval is required from FERC and RCA.

A statement from a ConocoPhillips Alaska spokeswoman said the company is pleased all parties reached a settlement and is looking forward to approval from state and federal regulators.

Ptacin said the dispute has lasted eight years and totaled $16 million just to litigate the first two years of rate cases.