Energy giant Exelon Generation has agreed to pay $200 million to help restore the Chesapeake Bay and protect parts of it from the impacts of climate change.

The deal ends a months-long lawsuit over the company’s operation of Conowingo Dam, the nearly century-old hydroelectric facility that is Maryland’s largest source of renewable energy.

Exelon and Gov. Larry Hogan’s administration had been fighting over how much the company should contribute to reversing the region’s declining water quality and mitigating pollution from upstream sources.

The deal, announced Tuesday by Hogan (R), would pour tens of millions apiece into an array of environmental and ecosystem projects, including a pilot program to dredge some sediment built up behind the dam, funding research, creating a mussel hatchery and making it easier for eels to swim through the dam, which sits on the Susquehanna River not far from the Maryland-Pennsylvania border.

The reservoir behind the dam filled with sediment years faster than scientists had predicted, making it an ineffective barrier for stopping pollutants from streaming into the Chesapeake, where they can smother underwater grasses and deprive fish and other wildlife of necessary oxygen.

Maryland Secretary of the Environment Benjamin H. Grumbles said Exelon’s money — some of which will be spent now, some over the next 50 years — represents an enormous boost to the state’s effort to improve the estuary’s health.

“We know the river and the bay are smiling because this is a huge investment,” Grumbles said in an interview.

Some of the projects will try to restore the river near the dam to more natural conditions. Others will try to limit how much “nutrient pollution” runs off farmland into waterways. And others seek to rebuild the ecosystem to better withstand warmer conditions and flash currents wrought by climate change, Grumbles said.

The efforts represent a fraction of the demands Maryland had tried to impose on Exelon, which owns the dam but needs state approval to secure a federal permit to operate it. Exelon sued Maryland last summer after the Hogan administration declined to renew the company’s expired license unless officials agreed to a list of conditions, which Exelon estimated would cost $7 billion.

Tuesday’s settlement must be approved by federal regulators before the operating permit can be renewed for 50 years.

Not all environmental advocates were pleased with the deal.

The Chesapeake Bay Foundation said Exelon’s spending will average $4 million a year over 50 years, a level that it says “falls short” of mitigating the effects of operating the dam. The sediment, nitrogen and phosphorous built up behind the dam can be released en masse during heavy rainfall, effectively “scouring” the bay as it rushes toward the ocean.

“Exelon can and should invest more,” said Alison Prost, the foundation’s executive director in Maryland.

The dam provides power for about 165,000 homes.

The deal includes $25 million for the mussel hatchery and $11 million to improve passage for eels through the dam, plus $52 million to enhance habitat for aquatic species. Another $19 million will go toward cover crops for farmers and to help forestry efforts, and $41 million will be spent on “enhanced debris management” that will skim trash and other flotsam from the water before it reaches the dam.

This story was updated after initial publication to reflect that the dredging project is limited to a pilot program.