Containership operators rushed to order new vessels during the pandemic as booming demand for consumer goods was expected to fuel global trade for years to come.

Their timing couldn’t have been worse.

The surge in demand proved temporary, and executives are bracing for years of industry damage from weak freight rates and more ships hitting the water than are needed.

Shipbuilders have orders totaling about 26% of the world’s containership capacity. The peak of those deliveries is coming over the next two years.

The overcapacity has left dozens of idled or underused vessels with freight rates barely covering sailing costs. The shipowners face tough talks with cargo owners in the coming months as they seek long-term contracts at rates less than half of what they were last year, according to people involved in the talks.

“What’s ahead of us is going to be a downturn because we face some serious overcapacity,” Vincent Clerc, the chief executive of Danish boxship giant

A.P. Moller-Maersk, told The Wall Street Journal. “I see another two to three years of weakness in the market, so we are taking comprehensive measures to shore up our balance sheet.”

Maersk, which operates more than 700 ships and is seen as a bellwether of global trade, said earlier this month that it was cutting more than 10,000 jobs across the company. Its third-quarter net profit slumped to $521 million from $8.88 billion in the same period last year, while revenue fell by 47% to $12.13 billion.

The postpandemic period has been one of sustained weakness with daily rates now hovering at 2019 levels, down 95% since the peak of the pandemic in 2021. It is a turnaround from a time when carriers were handing out generous bonuses, sometimes more than a year’s pay, to reward employees for bumper profits, according to boxship executives in Asia and Europe.

The weaker market has cut freight costs for big retailers such as Amazon and Target by around half, according to people familiar with the market. Some retailers are actively negotiating to lower prices agreed to under long-term freight contracts signed last year or earlier this year.

Average three-month rolling contracts for 2024 are being settled at around $2,000 per box, down from $6,000 this year, people involved in the talks said. Boxships make more than 60% of their earnings from longer freight agreements rather than spot rates that can swing substantially from week to week.

The top carriers next year are expected to report a combined loss of $15 billion, driven by prolonged weakness in freight rates, according to London-based shipping broker Drewry. Container lines are expected to make around $43 billion in 2023, down 80% from last year, according to estimates by owners and brokers.

“We are making the same mistake as in 2008-2010 when everybody ordered ships because we thought China would grow by millions of percent forever. We haven’t learned to control capacity,” said Nils Haupt, a spokesman for German carrier Hapag-Lloyd AG, the world’s fifth-biggest liner in terms of capacity.

The late 2000s financial crisis kicked off a wave of consolidation among the world’s 20 biggest carriers. By the end of 2019, about half the companies on that list had been swallowed up by bigger competitors or had gone bankrupt.

Owners and analysts don’t expect additional consolidation in coming years. Carriers generated hefty profits during the pandemic, and some are still sitting on large cash piles. As a result, owners will likely have to resort to cutting prices to win business, or canceling sailings or idling ships to keep costs in check.

Geneva-based Mediterranean Shipping Co. bought more than 200 ships during the pandemic to become the world’s biggest carrier, ahead of Maersk.

MSC, which now moves around 20% of all containers, operates a fleet of around 800 vessels. The company plans to remove some of those ships from service by scrapping them, but it didn’t say how many.

“MSC grew its fleet in order to meet the significant demand increases we saw during the pandemic, which helped keep world trade flowing and soften the impact of lockdowns,” an MSC spokesperson said.

He said new deliveries will help MSC control one of the youngest and most environmentally friendly fleets in coming years. The closely held company didn’t respond to questions about potential losses from new ships and doesn’t publicly disclose financial reports.

“Roughly a quarter of all sale and purchase deals from 2020 to 2023 has MSC’s name on it. They bought too many ships, and some are pretty old so it makes little sense to keep them,” said Peter Sand, chief analyst at Norway-based shipping platform Xeneta.

Write to Costas Paris at costas.paris@wsj.com