The longshore union and APM Terminals have struck a tentative deal to end the months-long battle over the future of automation and jobs at the Port of Los Angeles’ largest terminal, officials said Thursday evening, July 18.

APM Terminals, owned by shipping-container giant Maersk, and the association that represents port terminals have agreed, after months of closed-door meetings, to provide a comprehensive, fully paid retraining program for members of the International Longshore and Warehouse Union, said Tom Boyd, Maersk spokesman.

In exchange, the longshore union will allow APM’s permit to bring in zero-emission and near-zero-emission automated equipment to its terminal, on Pier 400, without further protest.

“This focus is on reskilling and upskilling” the workers, Boyd said. “Everyone is quite excited about it.”

Details on the retraining program were light Thursday, Boyd said, because the deal had just been agreed to.

But it appears to end more than a half-year of public turmoil over automation at the mammoth port complex.

In early January, Port of Los Angeles gave routine administrative approval to APM Terminals to bring in the automated equipment.

That equipment, Boyd said, will arrive from Poland this month and is necessary for the future of its operations.

But a month after the approval, the ILWU appealed the decision to the Los Angeles Board of Harbor Commissioners. That triggered a public hearing process and months of debate on the future of jobs and automation.

Longshore workers marched in the street. They lined up to speak at commission meetings. They vowed, via officials, not become “the next Detroit.”

Officials for APM Terminals, for their part, pointed to the most recent labor agreement allowing automation and contended — with a majority of harbor commissioners agreeing — that their permit was consistent with the Port Master Plan.

The original vote on the permit was set for April. But the commission delayed their decision for a month, so that Los Angeles Mayor Eric Garcetti could step in and mediate.

Then, a series of votes over the last two months threatened to send the dispute to court. First, the commission voted to reject the ILWU’s appeal, thus OKing the permit.

Second, L.A. City Councilman Joe Buscaino, who represents the San Pedro area in which the port sits, brought that decision before his colleagues. The L.A. council voted to send the permit application back to the harbor commission for another vote.

Finally, last week, the harbor commission once again affirmed the permit.

Union officials, at the time, said they’d have to look anew at their options.

Through it all, officials say, negotiations to resolve the impasse continued.

The agreement was worked out among the three parties, with the help of Garcetti’s office, Boyd said.

In a statement, APM Terminals said Garcetti’s “leadership” brought the parties together, adding that he insisted the modernization of Pier 400 couldn’t be completed unless ILWU workers were “equipped with the training and skills” to keep the port competitive.

Thursday’s deal is separate from the union’s current labor agreement and does not need approval from the Port of L.A., officials said.

“This tentative agreement will help longshore workers prepare for the port jobs of the future,” the Pacific Maritime Association, which represents terminal operators, said in a statement. “It is a comprehensive, fully-paid training program to reskill and upskill longshore workers to equip them for the next generation of work on the waterfront.”

The only potential roadblock, Boyd said, is that the City Council, which doesn’t meet again until August, could still send the permit back to the commission for a third look. But Boyd said he doesn’t expect that to happen.

“ILWU will get paid for training,” Boyd said. “It’s a win-win for everybody.”

Buscaino, though, in a statement said the conversation over the future of automation — despite Thursday’s agreement — is far from over. He called for Los Angeles to create a “Blue Ribbon Commission.”

That commission would look at “the future of work and automation in our city,” Buscaino said. “We must prepare for the future today because as this fight has shown, the future is already here.”

Officials for ILWU could not immediately be reached. L.A. port Executive Director Gene Seroka was unavailable for comment Thursday evening.

This story is breaking and will be updated.