A feder al judge on Friday upheld the Environmental Protection Agency’s sweeping plan to limit pollution in the Chesapeake Bay, derailing the farm lobby’s attempt to stop one of the largest efforts to clean a waterway in the nation’s history.

In a long-awaited decision, U.S. District Court Judge Sylvia H. Rambo wrote that “the ecological and economic importance of the Chesapeake Bay is well documented” and that the EPA is within its rights under the Clean Water Act to partner with the six states in the bay watershed to cut the pollution that pours in from sewers and construction developments, and particularly chemical and biological waste from farms.

“As the largest estuary in the United States, the Chesapeake Bay is essential for the well-being of many living things,” Rambo wrote. While noting attempts to “protect this important resource” without strong federal coordination for several years, Rambo wrote that “nutrient pollution and sedimentation remain a critical concern.”

The EPA embarked on an aggressive cleanup effort in 2010 that required Chesapeake Bay states, including Virginia and Maryland, as well as the District, to upgrade sewers to limit the amount of nutrient pollution that pours into the bay.

States also were required to find ways to stop agricultural runoff from cattle feed operations, chicken houses and other farms. That resulted in plans for fences to prevent cattle from wading into streams, sheds to store animal waste and other conservation upgrades that many farmers said they could not afford.

The American Farm Bureau Federation filed a lawsuit in early 2011 at the U.S. District Court for the Middle District of Pennsylvania to stop the EPA. Numerous organizations — including the Fertilizer Institute, National Pork Producers Council and National Chicken Council — joined the suit.

The Farm Bureau said the bay’s cleanup is the sole responsibility of states and the EPA lacked authority to establish a “pollution diet” costing taxpayers and farmers billions by its full implementation in 2025.

The lobby argued further that the EPA did not give the public adequate time to consider the plan in the run-up to its implementation in December 2010, saying that a 45-day comment period was too short.

Rambo rejected those arguments. “The court does not find the 45-day public comment period to be unreasonable,” she wrote. “For one, it exceeds the statutory minimum requirement of a 30-day period.”

As for the plan itself, “the court endorses the holistic, watershed approach used here,” Rambo wrote. “This approach receives ample support in the [Clean Water Act], its legislative history, and Supreme Court precedent.”

In a statement Friday, the EPA called the ruling “a victory for the 17 million people in the Chesapeake Bay watershed” and said its partners can refocus on achieving clean-water goals, “building on the progress already happening.”

A Farm Bureau spokeswoman said the organization was still reviewing the decision late Friday and could not comment.

The Chesapeake Bay Foundation, one of many environmental groups that signed on to the lawsuit in support of the EPA, said the ruling allows states to press ahead with strong direction from the courts.

Rambo wrote in her decision that the EPA and the states “have not only the authority, but the responsibility” to set pollution limits based on science, said Chesapeake Bay Foundation President William Baker. “We call on the opposition to stop attempting to derail clean-up efforts, lay aside expensive litigation, and roll up their sleeves and join Bay restoration efforts.”