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.

Specifically, the Arctic Ocean drilling case could give legal ammunition to opponents of Mr. Trump’s efforts to roll back protections for two million acres of national monuments created by Mr. Obama and President Bill Clinton.

The case adds to a growing roster of legal losses for Mr. Trump’s efforts to undo Mr. Obama’s environmental legacy. Experts in environmental law estimate that the Trump administration has now lost about 40 environmental cases in federal courts.

Most immediately, the decision will force the Interior Department to withdraw the waters of the Arctic Ocean from its forthcoming plan detailing where the federal government intends to lease federal waters to oil companies for offshore drilling. A draft of that plan published last year called for drilling off the entire United States coastline.

The White House referred questions on the matter to the Interior Department, where a spokeswoman declined to comment.

And although Friday’s court decision relates specifically to a law on offshore drilling, it could also hamstring Mr. Trump’s efforts to erase or reduce the creation of large protected areas of public lands by previous presidents.

“The statutes and the Supreme Court have been silent on the authority of a president to modify or reduce a predecessor’s protections of these public lands, waters and monuments,” said Patrick Parenteau, a professor of environmental law at Vermont Law School. “But these decisions are showing that if a president wants to reverse a predecessor’s environmental policy, they have to give a cogent reason why. Just saying ‘energy dominance’ is not enough. Saying ‘I won the election’ is not enough.”

Professor Parenteau predicted that the case was likely to reach the Supreme Court, though probably not for several years.

Both Mr. Obama’s efforts to use his executive authority to ban drilling in the Arctic Ocean, and Mr. Trump’s efforts to undo that ban, are legally unprecedented.

In using his executive authority to permanently ban drilling in most of the Arctic Ocean, Mr. Obama relied on an obscure provision of a 1953 law, the Outer Continental Shelf Lands Act, which governs how the executive branch uses federal waters for offshore energy exploration.

The law includes a provision that lets presidents put those waters off limits to oil and gas drilling. Presidents Dwight D. Eisenhower, Richard M. Nixon and Mr. Clinton used the law to protect sections of the Atlantic, Pacific and Arctic Oceans, but those protections came with time limits, usually one to two decades.

In late 2016, as he sought to legally cement environmental protections before Mr. Trump, then the president-elect, took office, Mr. Obama used what both supporters and critics called a creative and unusual interpretation of that law to set a permanent ban on drilling in most of the Arctic Ocean.

Three months after taking office, Mr. Trump issued an executive order rescinding the ban. That made him the first president to seek to revoke a decision by his predecessor to use the law to protect federal waters.

Environmental groups promptly sued the administration over the move. They welcomed Friday’s court decision.

“Since coming into office, Trump has been on an one-man campaign to undo the work of his predecessor,” said Niel Lawrence, a lawyer with the Natural Resources Defense Council, who took part in the oral arguments in the Alaska case. “What this opinion confirms is that there are constitutional limits to that.”

Erik Milito, a spokesman for the American Petroleum Institute, which lobbies for the oil industry and which joined the Trump administration’s case, said, “While we disagree with the decision, our nation still has a significant opportunity before us in the development of the next offshore leasing plan to truly embrace our nation’s energy potential and ensure American consumers and businesses continue to benefit from U.S. energy leadership.”

Experts said that Judge Gleason’s decision could affect the legal outcome of Mr. Trump’s efforts to roll back certain protections created by his predecessors on public lands.

Just as presidents have used the 1953 offshore-drilling law to protect federal waters, they have used a different law, the 1906 Antiquities Act, put in place by President Theodore Roosevelt, to designate and protect millions of acres of lands as permanent public monuments. Presidents throughout the past century have created such monuments.

While at least two presidents have used their authority to shrink the size of monuments created by their predecessors, Mr. Trump has done so at a more drastic scale. In December 2017, Mr. Trump cut about two million acres from two national monuments in Utah: the Bears Ears monument, created by Mr. Obama, and the Grand Staircase-Escalante monument, created by Mr. Clinton. At the time it was the largest rollback of federal land protection in the nation’s history.

Already, lawsuits on the issue are making their way through federal courts. Professor Parenteau and others predicted that Judge Gleason’s decision could possibly have a bearing on those cases.

That is because, in the language of both laws, Congress gave the president the right to occasionally designate public lands and waters for protection. However, each of the laws is silent on whether a successor can reduce or revoke those protections.

If Mr. Trump’s challengers win in court, the decision could affirm future presidents’ right to set bans of offshore drilling that could be undone only by Congress (as opposed to a later president) and similarly could set a precedent that presidential decisions to expand protections of public land could be revised or reversed only by Congress.

If Mr. Trump prevails in court, future presidents could potentially use an executive order to shrink any of the dozens of monuments created by their predecessors or similarly revoke presidential decisions to protect federal waters.

For more news on climate and the environment, follow @NYTClimate on Twitter.