Five years after oil from the Deepwater Horizon disaster tainted the Panhandle's sugar-white beaches, petroleum giant BP agreed Thursday to an $18.7 billion settlement with Florida, four other gulf states and the federal government.

Florida's share could be more than $3.25 billion, paid out over 18 years, state Attorney General Pam Bondi announced at a news conference in Tampa. She promised the settlement "will benefit areas of the state most devastated by the spill," though she did not provide a specific breakdown of how the money will be spent.

The settlement includes $5.5 billion paid over 15 years to cover pollution penalties under the federal Clean Water Act — a record fine under that landmark 1972 law.

Of the amount going to Florida, $2 billion is for the state's economic losses, primarily from tourism and the seafood industry.

"This is a realistic outcome which provides clarity and certainty for all parties," BP chief executive Bob Dudley said in a statement on Thursday. He said it "will resolve the largest liabilities remaining from the tragic accident and enable BP to focus on safely delivering the energy the world needs."

The settlement was announced just as a federal judge was preparing to rule on how much BP owed in federal Clean Water Act penalties after nearly 134 million gallons of oil spewed into the Gulf of Mexico in 2010. Earlier this week, the U.S. Supreme Court rejected appeals by BP and rig co-owner Anadarko to avoid Clean Water Act penalties.

The settlement was the best possible outcome for Florida, as opposed to gambling on the results of a trial, Bondi said. Some people disagreed.

"Considering this was the worst environmental disaster in history, and it was caused by gross negligence, the amount of penalties specifically for violations of the Clean Water Act could be — and, I think, should be — much larger," Sen. Bill Nelson, D-Fla., said in a statement.

Jacqueline Savitz of the environmental group Oceana contended that "BP will be getting off easy" compared to the damage it caused.

"We have serious concerns about how much of this money is actually going to be allocated towards restoring the gulf's environment and impacted communities," said Cynthia Sartou of the Gulf Restoration Network.

Some Florida restoration projects already approved include starting a ferry service, building a boat ramp, fixing a boardwalk and putting solar-powered lights on a fishing pier in the Panhandle. State officials say those are considered "gulf restoration" projects because they restore tourist access.

The Deepwater Horizon disaster began in April 2010 with an explosion that killed 11 crew members. The rig sank 5,000 feet to the bottom of the gulf and began gushing oil.

Because the leak happened so far from the surface, BP could not immediately figure out a way to shut it off. Underwater robots sent down to monitor the spill broadcast live footage of the oil gushing from the rig, footage shown around the world.

The spill created a slick on the surface that was large enough to see from space. The oil washed ashore in marshes and on beaches from Louisiana across the gulf, reaching the Florida Panhandle in June.

To try to stop the oil from reaching shore, BP sprayed a record amount of the chemical dispersant Corexit. The company even sprayed the dispersant deep underwater as the oil shot out of the broken rig, something that had never been tried before.

The dispersant created an underwater plume of oil droplets that snaked through the gulf's deep canyons, a crucial habitat for commercially valuable fish.

The spill hurt Florida's tourism industry as images of oiled beaches and birds went around the world, convincing visitors to cancel reservations even in parts of the state where no more than mere traces of the oil washed up. Tourism eventually bounced back, but scientists are still assessing the environmental damage.

The oil killed pelicans, oysters, dolphins, coral and sea turtles, and caused heart damage to bluefin tuna and deformities among shrimp, killifish and crabs.

When anglers caught fish with ugly lesions, scientists from the University of South Florida pointed to damaged immune systems likely caused by contact with the oil.

They also found oil buried deep in the sediment around where the oil rig sank, like a dirty bathtub ring. They also discovered that the oil killed millions of amoeba-like creatures in the area of the spill. More recently they discovered minute amounts of oil in sandy patties that washed up on Pinellas County's Sunset Beach. And last year a crew from the state Department of Environmental Protection found a 1,250-pound tar mat that measured 9 feet long in the surf off Pensacola Beach.

Meanwhile thousands of people hired to help clean up the spill are experiencing problems with their respiratory systems that may be tied to exposure to the oil, according to an ongoing study by the National Institutes of Health. The incidence of wheezing and coughing was 20 to 30 percent higher among the cleanup workers than among the general public. That's not something addressed by the settlement.

BP, which had $12.1 billion in profits in 2014, has said its spill-related costs already exceed $42 billion — even without the Clean Water Act fine. It's also unclear how much BP will end up paying under a separate 2012 settlement with individuals and businesses claiming spill-related losses.

However, the price of shares in BP rose as news of Thursday's settlement spread.

Times staff writer Shaker M. Samman and researcher Caryn Baird contributed to this report, which includes information from the Associated Press. Contact Craig Pittman at craig@tampabay.com. Follow @craigtimes.