A federal judge on Friday delivered a blow to the Trump administration’s effort to expand offshore drilling, restoring bans in vast parts of the Arctic Ocean and dozens of canyons in the Atlantic Ocean.

In Alaska, U.S. District Court Judge Sharon Gleason threw out President Donald Trump's 2017 executive order overturning Obama-era restrictions.

Federal law allows presidents to remove certain lands from development, Gleason said, but not reverse bans. Only an act of Congress can revoke the withdrawals, she said.

The environmental bans issued by former President Barack Obama in 2015 and 2016 were aimed to protect polar bears, walruses, ice seals and Alaska Native villages that depend on the animals.

Frozen feces:Climate change could melt decades worth of human poop at Denali National Park in Alaska

Energy agenda:Trump administration set to roll out massive offshore oil plan, but many in GOP don't want it

The American Petroleum Institute, a defendant in the case, disagreed with the decision.

“In addition to bringing supplies of affordable energy to consumers for decades to come, developing our abundant offshore resources can provide billions in government revenue, create thousands of jobs and will also strengthen our national security,” it said in a statement.

Erik Grafe, an attorney with Earthjustice, said the judge's ruling will help safeguard oceans and wildlife from fossil fuel interests. The organization represented environmental groups that sued the Trump administration over the executive order.

Acting Assistant U.S. Attorney General Jeffrey Wood said the groups misinterpreted the Outer Continental Shelf Lands Act at issue during a hearing before Gleason last year. He argued the act is meant to be flexible and not bind presidents to another's decisions.

Obama halted exploration in coastal areas of the Beaufort and Chukchi seas and the Hanna Shoal in 2015. The following year, he withdrew most other potential Arctic Ocean lease areas — about 98 percent of the Arctic outer continental shelf.

To protect marine mammals, deep-water corals, valuable fish populations and migratory whales in the Atlantic, Obama banned exploration in 5,937 square miles of underwater canyon complexes.

The Trump administration's current proposal to expand offshore oil and gas drilling faces bipartisan, bicoastal opposition due to pollution concerns along coasts and beaches.

Contributing: The Associated Press