LOS ANGELES — Labor-management peace is returning to West Coast seaports – and with it, eventually, the free flow of cargo across docks that handle about one-quarter of U.S. international trade.

On Friday night, negotiators for dockworkers and their employers reached a tentative, five-year contract deal. The agreement’s immediate effect is to restore normal operations at 29 Pacific ports where dozens of huge ships are waiting to unload a shopper’s delight of imported goods. U.S. exports, particularly from farms, are also waiting to reach Asian markets.

It will take several months for ports such as Los Angeles and Long Beach – the nation’s largest – to clear the backlog, which swelled as the two sides quarreled over a new deal.

In recent months, a tit-for-tat dynamic developed where dockworkers first slowed down by closely following safety rules and employers responded by cutting night, weekend and holiday shifts – saying they did not want to pay overtime for what amounted to a “strike with pay.” It was the kind of brinksmanship familiar from past negotiations between two sides with a history of conflict that dates to the killing of dockworkers during the Great Depression.

While the ports never shut down fully, the problems in the supply chain were acute.

On Saturday, the leader of the Port of Los Angeles estimated that it would take three months “to get back a sense of normalcy.” While there are about 30 ships just off the coast – a visual reminder of the extent of the backlog – there are perhaps two dozen more hanging beyond the horizon, executive director Gene Seroka said.

He planned to draw up a detailed plan for which ships get priority, with a preference for those carrying perishables such as produce or serving U.S. military bases on the Pacific Rim.

“The sense of urgency in the industry right now is as good as I’ve ever seen it,” Seroka said.

The smaller Port of Oakland reckoned it would take up to eight weeks to recover.

By Saturday morning, smaller work crews were preparing dockside yards for a return to full work in the evening.

All told, West Coast ports handle about $1 trillion worth of cargo annually.

The tentative contract reached Friday evening in San Francisco still must be approved by the 13,000-member International Longshore and Warehouse Union’s rank-and-file, as well as the full Pacific Maritime Association of employers.

A vote by union members could come in April. It was not immediately clear when employers would vote on the contract.

Neither side released details, but in a recent letter, maritime association President James McKenna outlined what he called employers’ “last, best and final” offer. It included maintenance of nearly no-cost health coverage, an $11,000 increase in the maximum pension benefit to $91,000, and a $1-per-hour wage increase over each of the five years.

Though dockworker wages vary by job and skill level, the average exceeds $50 per hour, according to the maritime association, which represents ocean-going shipping lines and the companies that load and unload cargo at port terminals.

Negotiators began talking formally in May. Their prior six-year contract expired July 1.

When a federal mediator couldn’t broker a final agreement, the Obama administration dispatched Labor Secretary Thomas Perez to oversee talks this week. He warned negotiators that if they didn’t seal a deal by midnight Friday, he’d haul them back to Washington, where a parade of elected leaders had been imploring resolution.