The attorneys general of Alabama, Louisiana, Florida and Mississippi settled “in principle” with the fallen oil giant British Petroleum (BP) on Thursday, agreeing to accept $18.7 billion in damages after a judge deemed the company “grossly negligent” in the costliest offshore environmental accident in U.S. history.

“This is a landmark settlement,” Gov. Robert Bentley of Alabama said in a statement. “It is designed to compensate the state for all the damages, both environmental and economic.”

Officials from all four states presented the deal as a major step forward, a win for the people and their natural resources. Bob Bendick, who directs the Nature Conservancy’s Gulf of Mexico program, agreed, telling msnbc that the money could fund the kind of large scale habitat restoration that the area needs.

RELATED: Study links 2010 BP oil spill to dolphin deaths

But other environmental groups weren’t so convinced. “If the court approves this proposal, BP will be getting off easy and ‘we the people’ will not be fully compensated,” Jacqueline Savitz, a vice president for Oceana told msnbc. “$18.7 billion may sound like a lot of money, and it is, but it pales in comparison to what BP owes.”

The Deepwater Horizon disaster killed 11 rig workers, blew the cap off of an undersea oil well, and gushed more than 100 million gallons of crude before crews could pinch it shut. The announcement came unexpectedly, just three days after the Supreme Court declined to hear BP’s appeal in an earlier case. That decision set BP up for as much as a $13.7 billion fine under the Clean Water Act alone. Under the terms of the new agreement, the company’s fine under the Clean Water Act will be just $5.5 billion.

Similarly, the restoration costs paid by Exxon after the smaller Valdez spill of 1989 suggested that BP’s payout could be in range of $30 billion, Savitz argued. Under the terms of the new agreement, however, BP will pay only $7.1 billion.

In September, U.S. District Judge Carl Barbier in New Orleans seemed to set BP up for much steeper penalties. He found BP liable for the oil that belched from its faulty well head in the Gulf of Mexico in April of 2010. While he and BP haggled over the total size of the spill, the repercussions were never in doubt.

The spill coated a delicate undersea world in black, killing fish, coral and wildlife and bringing a tide of trouble to shore. Tourism cratered. The fishing industry failed. And residents complained of property erosion (from dead sea grass) and respiratory problems from spill-related vapors.

The timing of the deal also struck some as troubling, a classic bad news dump hastily arranged hours before much of the county logs off and heads outside for the holiday. Indeed, the fine is the largest in the history of the Clean Water Act – but it’s dramatically less than what it could have been before years of successful legal wrangling by BP.

The settlement comes after a long line of court decisions and judiciary handicapping and horse-trading, which started even before the well was capped. At some level the state and federal government seemed tired of pouring taxpayer dollars into the legal fight. Florida Attorney General Pat Bondi said the deal averted a legal “black hole.”

The legal drama began back in 2011, after a federal investigation blamed the blowout on faulty cement work in the well, and fingered BP for the shoddy work. It also accused the once-dominant company of skimping on safety measures to ramp up profits.

A year later, BP accepted criminal responsibility for the disaster, including 11 counts of manslaughter and one count of lying to Congress. It paid the Justice Department a $4.5 billion dollar fine, the first of rolling penalties that have been extremely costly for the company. In all, BP set aside $45.5 billion to cover the spill, including $3.5 billion for civil penalties, victim compensation, and clean-up.

The costs piled up quickly, however, and last fall’s federal ruling by Judge Barbier threatened to put an additional $18 billion cash-hole in the company’s recovery. “BP’s conduct was reckless,” Barbier wrote in his ruling, which also concluded that BP was “grossly negligent” in the run up to the disaster. That set the company up for penalties as high as $4,300 per barrel spilled – four times higher than the fine he suggested for BP’s drilling partners.

Since that ruling, however, the company has managed to lower the official spill amount by more than a million barrels. It’s also managed to shave more than seven billion off its maximum environmental fine. Thursday’s deal includes $5.9 billion to settle claims by state and local governments for economic damages they have suffered as a result of the spill. It also includes $600 million for other undisclosed claims, $700 million for long term environmental problems that scientists have yet to uncover.

But the total is still likely to come in close to BP’s original estimate of the spill’s total cost. Plus, the payments will be made over time, not as a lump sum.

BP shares rose 5% on news of the deal.