It turns out that unraveling Barack Obama’s environmental agenda is harder than it looks.

Federal judges have ruled against the Trump administration three times in the last three days, arguing that the administration short-circuited the regulatory process in its push to reverse policies on water protections, chemical plant safety operations and the controversial Keystone XL pipeline. In each instance, the courts either reinstated the existing rule or delayed the administration’s proposal from taking effect.

On Friday, the U.S. Court of Appeals for the District of Columbia Circuit ruled that the Environmental Protection Agency’s move to delay new chemical and safety requirements was “arbitrary and capricious.” The day before, a judge on the U.S. District Court in South Carolina reinstated a rule in 26 states limiting the dredging and filling of streams and waterways on the grounds that the EPA had not solicited sufficient public input. And on Wednesday, a judge on the U.S. District Court of Montana ordered the State Department to conduct a more extensive environmental impact statement of the Keystone XL’s proposed route through Nebraska.

“It’s certainly been a very bad week for EPA’s deregulatory agenda," said Georgetown University law professor Lisa Heinzerling, who served as a senior EPA official under Obama. The recent decisions come on the heels of a major loss for the administration Aug. 9, when the U.S. Court of Appeals for the Ninth Circuit ordered the EPA to ban a widely used pesticide known as chlorpyrifos, linked to developmental problems in children, within 60 days. In March 2017, then-EPA Administrator Scott Pruitt had rejected a petition by environmental and public health groups to take the pesticide off the market.

The recent rulings all date back to decisions made early in President Trump’s tenure — often at the urging of industry groups who accused Obama officials of federal overreach. In the case of the Risk Management Plan amendment, or Chemical Disaster Rule, which was reinstated Friday, chemical manufacturers and refiners had urged the EPA to suspend a rule aimed at promoting safety at chemical plants.

The rule was crafted in response to the 2013 fertilizer plant explosion in West, Tex., that killed 15 people, including a dozen first responders. It requires companies to better coordinate with emergency responders, share information about chemical threats with local communities and assess whether alternative technologies could prevent injuries in the case of a chemical accident.

In Friday’s decision, judges Judith Rogers and Robert Wilkins stated that the EPA’s argument that industry needed 20 months to determine how to meet the new standards “makes a mockery of the statute.”

In other losses last week, a federal judge in Los Angeles ordered the EPA to restrict stormwater discharges from commercial and industrial sites, and the U.S. Court of International Trade halted imports of all seafood caught with gillnets in Mexico because the practice threatens the critically endangered vaquita porpoise. Noting that Trump officials sought to modify the ban, Judge Gary S. Katzmann wrote that it did not make sense given that “there is a real danger that the vaquita will disappear from the planet.”

“What the courts are saying is we’re going to enforce the laws that Congress wrote, and this administration is breaking those laws, and needs to stop,” said Natural Resources Defense Council’s litigation co-director Michael Wall.

Myron Ebell, who directs the Center for Energy and Environment at the conservative Competitive Enterprise Institute, said in an interview that “there are likely to be setbacks in court” when federal officials undertake major rules changes. He noted that the Supreme Court stayed the Obama administration’s Clean Power Plan, which limited greenhouse gas emissions from existing power plants.

Ebell said “several factors” contributed to the recent legal losses, including the fact that “Pruitt was a lot more about advocating and promoting the Trump agenda, rather than being on top of it.”

In other losses over the past week, federal judges in California ordered the EPA to restrict stormwater discharges from industrial operations and overruled a Fish and Wildlife Service policy

D.C. Circuit Judge Brett Kavanaugh was a member of the three-judge panel that heard arguments in the case but withdrew after being nominated for the Supreme Court.

Asked for comment Friday, EPA spokeswoman Enesta Jones said agency officials “are reviewing the decision.”

It remains unclear whether the administration will appeal some of these rulings, and if so, whether the Supreme Court would intervene. Heinzerling noted that given the Supreme Court’s more conservative tilt, there is a chance it would rule differently from the lower courts. But she added that several setbacks involve “really plain administrative law,” which is less a matter of ideology than “pretty basic errors.”

“It would be very surprising if the Supreme Court would reverse them all,” she said.

Ebell, for his part, said that his greatest concerns is that these legal battles will drag on for a couple more years.

“One of the things our side has to worry about is that some of these legal disputes might not be resolves until a second Trump term. And we might not get a second Trump term,” he said. “The voters get to decide that.”

Chris Mooney contributed to this report.