LONG BEACH, Calif. — Day after day, Walter Diaz, an immigrant truck driver from El Salvador, steers his 18-wheeler toward the giant ports of Los Angeles and Long Beach. Will it take him a half-hour to pick up his cargo? Or will it be as long as seven hours? He never knows.

Diaz is paid by the load, so he applauds the arrival of more waterfront robots, which promise to speed turnaround times at a port complex that handles about a third of the nation’s imported goods.

“I’m for automation,” Diaz says. “One hundred percent.”

But what about the thousands of International Longshore and Warehouse Union workers who have mounted massive protests, saying the robots will replace human jobs? The ILWU members, who transfer cargo from ships to trucks and direct terminal traffic, “don’t care about the drivers,” said Diaz, 41, who has worked at the ports for two decades. “We sit in line while they take two-hour breaks. With automation, we don’t have that problem.”

The arrival of robots at the nation’s largest marine terminal, a 484-acre facility run by Danish conglomerate A.P. Moller-Maersk, is exposing a stark economic divide between two sets of Southern California workers.

On one side are well-paid union members, many third-and fourth generation dockworkers. On the other is a nonunion, largely immigrant and Spanish-speaking, workforce of independent contractors, who lack the hourly pay, overtime guarantees, pensions, health-care insurance and job security that ILWU workers enjoy.

The powerful longshore locals, with 9,300 registered members, captured public attention this year, battling Maersk’s plans with marches through the San Pedro section of Los Angeles, boisterous public hearings, community petitions, and support from elected officials. In the end, they couldn’t stop the project because in exchange for higher pay and better benefits over the years, ILWU contracts have explicitly allowed for automation.

Notably, throughout the four-month uproar, the ports’ 13,000 truckers were all but absent from the debate.

“The truckers are mostly nonunion, so they don’t vote as a block or make political contributions as a block,” said Wim Lagaay, chief executive of Maersk’s APM Terminals North America. “They don’t have a voice.”

But on private Facebook pages, which count thousands of drivers, they do.

There, truckers celebrate automation and rail against dockworkers and city politicians. And

they excoriate the dockworkers:“Hopefully automation kicks in and then all these lazy … longshoremen start collecting unemployment.”

At Maersk’s sprawling APM terminal, also known as Pier 400, the first batch of 50-foot-high robots, painted baby blue, loom over stacks of brightly colored containers holding everything from sneakers and toys to computers and auto parts. Over the next three years, 100 of the driverless straddle carriers, as they are called, will replace 200 cranes and trucks operated by 500 union dockworkers across the facility’s 26 miles of roads. The robots, guided by remote computers using WiFi, will deliver cargo to trucks parked outside the container storage yard.

They are expected to slash average turnaround times to an estimated 35 minutes for 4,000 trucks that enter the terminal daily. In September, Maersk had the ports’ worst average turn times, averaging 96 minutes.

Maersk’s facility is not the first of the twin ports’ 13 terminals to introduce robots. Two smaller sites — the Long Beach Container Terminal, also known as Pier E, and TraPac, at the Port of Los Angeles — have largely automated over the last five years. Both now have the shortest cargo turn times at the ports, less than half those of Maersk’s APM.

For the 200,000 U.S. businesses importing goods through the San Pedro Bay ports — from such giants as Walmart and Apple to small factories and neighborhood stores — the speed with which their cargo moves from ships to trucks or trains, and on to consumers, is crucial. Trucking turn times are a key element of supply chain logistics as the ports, plagued by congestion, lose market share to East Coast and Gulf Coast rivals.

With high labor costs and costly environmental regulations, the Los Angeles and Long Beach complex “is the most expensive in the U.S.,” Maersk’s Lagaay said. And now, with the widening of the Panama Canal, ports along the East and Gulf Coasts are attracting more ships from Asia that have historically berthed in Southern California.

Automation, he said, will make his terminal “more competitive. If you don’t remain cost competitive, you lose business.”

To be sure, the truckers make more money by moving loads faster. But that’s not the only reason they favor the robots, said Weston LaBar, chief executive of the Harbor Trucking Associationn. At automated terminals, “no one’s rude to them. The machines are more polite than the longshoremen.”

Tensions between truckers and dockworkers are “cultural,” LaBar added. “Most people in the ILWU are from families that have been in the union for generations. Whereas the trucking community is made up of a lot of immigrants, and English is their second language. They get treated really unfairly.”

ILWU officials reject drivers’ claims that they are disrespected. They blame terminal operators, saying tensions result from technology glitches or skimping on staffing. As they see it, cargo flow — and tempers — would be smoothed with more security guards to direct traffic and more clerks to service machine operators.

As for dockworkers’ lunch and rest breaks, truckers would not object if they too were union members, entitled to similar privileges, ILWU officials contend. They trace the roots of resentment to the deregulation of trucking in the 1980s, which spurred a massive national shift from unionized truckers to independent contractors.

“Large corporations pit worker against worker,” said Joe Gasperov, president of ILWU Local 63, which represents the clerks. “I feel sorry for the truckers. They’re exploited. They’re paid by the load, not the hour, so they assume all the risk of terminal delays. And some companies care more about saving a buck than servicing the trucks.”