A U.S. appeals circuit court on Monday upheld a federal program aimed at reducing pollution in the Chesapeake Bay watershed, despite a challenge from farmers, builders and the attorneys general of 21 states located mostly outside the region.

The unanimous ruling, by a three-judge panel of the U.S. Circuit Court of Appeals in Philadelphia, affirmed U.S. Environmental Protection Agency restrictions on wastewater treatment and runoff from farms and construction.

The guidelines place limits on the amount of nitrogen, phosphorous and sediment that are allowed into the watershed. The EPA and scientists have said that the bay absorbs too much of those elements to maintain a healthy ecosystem.

Maryland, Virginia and the District of Columbia supported the EPA regulations and agreed to implement them.

The American Farm Bureau Federation, which helped lead the fight against the EPA program, argued that plan infringed upon states’ authority to regulate their own waterways. A host of industry groups joined the lawsuit, including the Fertilizer Institute and the Association of Home Builders and the National Chicken Council.

But the appeals court said in its ruling that “Congress made a judgment in the Clean Water Act that the states and the EPA could, working together, best allocate the benefits and burdens of lowering pollution.”

Six watershed states and the District of Columbia had already agreed to implement the EPA program, which stemmed from President Obama’s 2009 executive order to restore the Chesapeake’s health. The states include Delaware, Maryland, New York, Pennsylvania, Virginia and West Virginia.

The Farm Bureau declined to comment on the ruling Monday, saying it would be reviewing the decision and weighing its options for the next several days. The industry groups have 90 days to appeal the ruling to the full circuit court or the U.S. Supreme Court.

Environmental advocates applauded the court’s decision.

“This is a great day for clean water, and it’s a great day for all 17 million people who live in the Chesapeake Bay watershed,” Chesapeake Bay Foundation president William Baker said in a news conference.

Six watershed states and the District of Columbia had already agreed to implement the EPA program, which stemmed from President Obama’s 2009 executive order to restore the Chesapeake’s health. The states include Delaware, Maryland, New York, Pennsylvania, Virginia and West Virginia.

Attorneys general from 21 mostly-Midwestern states joined the Farm Bureau in its challenge of the regulations, arguing that the EPA would try next to impose similar programs for their watersheds, including the Mississippi River Basin.

“We find it an obscene irony that 21 attorneys general, 20 of whom are outside the Chesapeake watershed, would join in a lawsuit to stop us from cleaning up our backyard,” Baker said.

West Virginia Attorney General Patrick Morrissey (R) was the only attorney general in the Chesapeake region to join the challenge, despite West Virginia signed on to the program. His predecessor, Democrat Darrell McGraw, was in office at the time of the agreement.

The EPA program calls for participating states to implement 60 percent of the proposed actions by 2017 and all of them by 2025.