(CNN) A federal judge in Alaska has ruled an executive order by President Donald Trump allowing offshore oil drilling of tens of millions of acres in the Arctic Ocean is "unlawful and invalid."

The ruling on Friday from US District Court Judge Sharon Gleason means a drilling ban for much of the Arctic Ocean off of Alaska will go back into effect.

On April 28, 2017, Trump issued an executive order reversing three memoranda and one executive order in 2015 and 2016 by then President Barack Obama withdrawing about 125 million acres of the Arctic Ocean from oil leasing. The Obama order also prevented drilling in certain parts of the Atlantic Ocean.

That action by the Obama Administration prompted strong criticism from some Alaska politicians and oil companies that wanted to drill there.

Ten environmental groups, including Greenpeace, the League of Conservation Voters, Sierra Club and The Wilderness Society, filed suit to block Trump's executive order. Defending the order were the Trump administration, the American Petroleum Institute and the state of Alaska.

Read More