A federal judge in Alaska has reinstated a ban on oil-and-gas drilling in vast swaths of the Arctic Ocean, potentially undermining a central part of the Trump administration’s effort to expand offshore drilling.

Mr. Trump will need congressional authority, according to the ruling, to reopen drilling in Arctic areas and smaller parts of the Atlantic Ocean that the Obama administration put off limits just weeks before President Obama left office. The late Friday ruling invalidates an executive order Mr. Trump issued during his...