Kearny’s unwavering battle to close and cap the hydrogen sulfide-emitting Keegan Landfill was resolved peacefully Thursday at the New Jersey Sports and Exposition Authority headquarters, where the state agency unanimously ruled to settle with the town.

The resolution, which precedes an imminent legal settlement, will permanently close the landfill, cap it and pay Kearny up to $250,000. Once the landfill is capped, it will be transformed into a passive recreational space with public access to a nearby marsh, the resolution says.

Kearny and the NJSEA began discussions about the settlement about two weeks ago, and it may be complete by Monday, Kearny Mayor Al Santos said.

At Thursday’s meeting, the mayor graciously thanked the officials who he and his residents consistently implored to change their course.

“Our community persisted, and they were finally heard and you’re now taking right steps,” the mayor said.

NJSEA Chairman John Ballantyne said he respected Kearny’s united effort.

“It was amazing to see the town of Kearny come together as a community,” he said. “We can appreciate that.”

Kearny, the NJSEA and the state Department of Environmental Protection have already begun planning for how the landfill will be capped, Santos said.

The west side of the landfill will be the first section covered, and should be completed by the end of 2020, Santos said. The east side will be fully capped the following year, which Santos called a “very aggressive schedule.”

The legal battle began last April when Kearny sued the NJSEA with concerns about the landfill emitting hydrogen sulfide at rates higher than the state’s standard. The invisible gas with a powerful rotten-egg smell — caused by decaying sheetrock and wallboard — carried to residential areas and raised both health and quality-of-life concerns. Symptoms that result from inhaling it include dizziness, nausea and confusion.

Kearny installed a system to monitor the levels of gas output and on occasion would cancel sports practices at a neighboring field when the city deemed emissions too high.

The court ruled in the town’s favor at the end of September and ordered the landfill closed, despite the state agency’s efforts to mitigate the odor by installing a gas containment and collection system. The NJSEA, which earned millions each year in dumping fees at the landfill, then decided to appeal.

The upcoming settlement reverses that course.

Santos thanked his residents Thursday for their persistence in attending government meetings, discussing the issue with their neighbors and campaigning on social media.

“This is a collective success for all of us,” he said.