Editor's note: This story has been updated with a statement from Formosa.

A federal judge approved a historic settlement agreement Tuesday between Taiwan-based plastics manufacturer Formosa and a scrappy environmental activist represented by indigent legal services nonprofit Texas Rio Grande Legal Aid.

TRLA said the $50 million settlement is the largest in U.S. history involving a private citizen's lawsuit against an industrial polluter under federal clean air and water laws. The money will be poured into a trust over the next five years and used to pay for programs supporting pollution mitigation, habitat restoration, public education and other environmental efforts on the middle Texas Gulf Coast.

Diane Wilson, a retired shrimper and an environmental activist, sued Formosa in July 2017, alleging that its Port Comfort plant had illegally discharged thousands of plastic pellets and other pollutants into Lavaca Bay and other nearby waterways. Environmental group San Antonio Bay Estuarine Waterkeeper, represented by two private attorneys, joined Wilson in the suit.

In its defense, Formosa — which is in the process of expanding the plant — argued that a $121,875 fine against it by the Texas Commission on Environmental Quality, the state's environmental regulatory agency, made the lawsuit moot.

The Texas Tribune thanks its sponsors. Become one .

But U.S. District Judge Kenneth M. Hoyt strongly disagreed in a June ruling, calling the company a "serial offender" and saying that "the TCEQ’s findings and assessment merely shows the difficulty or inability of the TCEQ to bring Formosa into compliance with its permit restrictions."

Hoyt approved the $50 million settlement, which the parties announced in October, on Tuesday during a hearing in Victoria.

“Having the $50 million settlement go to local environmental projects feels like justice,” Wilson said in a statement. “Formosa polluted Lavaca Bay and nearby waterways for years. Now it will pay for strong community projects that will improve the health and welfare of our waterways and beaches.”

In a statement, TLRA noted that the settlement is not only the largest citizen suit settlement in U.S. history, but the largest by far — five times larger than the next highest clean water settlement and tens of millions of dollars more than the next highest clean air settlement, which Texas environmental groups won in a case against ExxonMobil.

During the weeklong trial in the Formosa case, which began in late March, Wilson and Waterkeeper members dragged in boxes full of thousands of milky white plastic pellets they had painstakingly collected from Lavaca and Matagorda bays and Cox Creek with the help of volunteers.

Formosa released a statement Tuesday afternoon that said the company "has agreed to implement a range of improvements to the wastewater and stormwater discharge facilities" at the plant. Those include installation of holding ponds to contain all stormwater on the property, improved capacity for its stormwater drainage systems and other changes designed to keep plastics out of the plant's wastewater.

The Texas Tribune thanks its sponsors. Become one .

In a statement issued in October when the settlement was announced, the executive vice president for the U.S. branch of Formosa said the conditions laid out in the agreement "demonstrate Formosa’s commitment to manufacturing our products in a safe and environmentally friendly manner.

“We will continue to partner with local communities and stakeholders to ensure that [Formosa Plastics Corporation] USA environmental programs are at the top of our industry," Ken Mounger said.

Under the settlement, Formosa agreed to comply with “zero discharge” of all plastics in the future and to clean up existing pollution. Hoyt inquired about that progress during the hearing Tuesday, saying he wanted to make sure it became a reality.

The Texas Tribune thanks its sponsors. Become one .

If Formosa is found to be in violation again, additional fines for each documented discharge will be paid into the settlement fund. The first penalty would cost the company $10,000 per discharge this year, with yearly increments climbing to more than $54,000 per discharge.