Smokestacks emitting greenhouse gases. Photo courtesy Environmental Protection Agency

A federal district court has ruled that California’s coordination with Canada’s Quebec province in a cap-and-trade carbon emissions market is constitutional, a blow to the Trump administration made public in a filing late on Friday.

In October, the Trump administration sued California for entering a climate agreement with Quebec, saying the state had veered out of its lane in linking with a market in another country and had no right to conduct foreign policy.

The decision by the U.S. District Court for the Eastern District of California this week said the Trump administration had “failed to identify a clear and express foreign policy that directly conflicts with California’s cap-and-trade program.”

President Trump has pursued a policy of maximizing fossil fuel output while slashing environmental regulations. He intends to pull the United States out of the 2015 Paris agreement on climate change.

California, the most populous U.S. state and one of the five largest economies in the world, has long positioned itself as a leader on taking action against climate change. It agreed with Quebec in 2013 to link markets that aim to cut emissions of gases blamed for warming the planet.

The Trump administration has suffered several major losses in the courts on environmental issues and energy pipelines. This week a federal judge in California blocked the administration’s plan to roll back a rule that would slash methane emissions from oil and gas operations on federal lands.

The Department of Justice did not immediately respond to a request for comment about the ruling on California’s carbon emissions market.

Environmentalists cheered the decision. “The federal government should be doing everything in its power to fight climate change, not fighting the states that are leading the way,” said David Pettit, a lawyer at the Natural Resources Defense Council.