PORTLAND, Me. — In the vast gulf that arcs from Massachusetts’s shores to Canada’s Bay of Fundy, cod was once king. It paid for fishermen’s boats, fed their families and put their children through college. In one halcyon year in the mid-1980s, the codfish catch reached 25,000 tons.

Today, the cod population has collapsed. Last month, regulators effectively banned fishing for six months while they pondered what to do, and next year, fishermen will be allowed to catch just a quarter of what they could before the ban.

But a fix may not be easy. The Gulf of Maine’s waters are warming — faster than almost any ocean waters on earth, scientists say — and fish are voting with their fins for cooler places to live. That is upending an ecosystem and the fishing industry that depends on it.

“Stocks are not necessarily showing up in the places that they have in the past,” said Meredith Mendelson, the deputy commissioner for Maine’s Department of Marine Resources, which regulates fisheries. “We’re seeing movement of stocks often north and eastward.”