Want climate news in your inbox? Sign up here for Climate Fwd:, our email newsletter.

WASHINGTON — In a major legal blow to President Trump’s push to expand offshore oil and gas development, a federal judge ruled that an executive order by Mr. Trump that lifted an Obama-era ban on oil and gas drilling in the Arctic Ocean and parts of the North Atlantic coast was unlawful.

The decision, by Judge Sharon L. Gleason of the United States District Court for the District of Alaska, concluded late Friday that President Barack Obama’s 2015 and 2016 withdrawal from drilling of about 120 million acres of Arctic Ocean and about 3.8 million acres in the Atlantic “will remain in full force and effect unless and until revoked by Congress.” She wrote that an April 2017 executive order by Mr. Trump revoking the drilling ban “is unlawful, as it exceeded the president’s authority.”

The decision, which is expected to be appealed in the Ninth Circuit Court of Appeals, immediately reinstates the drilling ban on most of the Arctic Ocean off the coast of Alaska, a pristine region home to endangered species including polar bears and bowhead whales where oil companies have long sought to drill. Along the Atlantic coast, it blocks drilling around a series of coral canyons that run from Norfolk, Va., to the Canadian border which are home to unique deepwater corals and rare fish species.

In addition, Friday’s ruling by the judge, an Obama appointee, has broader implications for Mr. Trump’s effort to push drilling across the American coastline and on public lands.