Clerical workers at the ports of Los Angeles and Long Beach will return to work Wednesday, ending a strike that crippled America’s busiest shipping hub for more than a week.

Leaders of the 800-member International Longshore and Warehouse Union Local 63 Office Clerical Unit agreed to a tentative deal after marathon negotiations that ended late Tuesday. The deal will not become final until it is ratified by the full union membership.

It ends a grueling battle between both sides that threatened to damage the fragile U.S. economy. Since the strike began, 20 ships diverted to rival ports in Oakland, Ensenada and Panama, while other freighters docked offshore waiting for a resolution.

“This was at a critical juncture,” said Jack O’Connell, an international trade economist. “The national economy is still trying to get on its feet and this strike would have been decidedly unhelpful. There are enough head winds out there already.”

The deal came after Los Angeles Mayor Antonio Villaraigosa called in two federal mediators Tuesday morning to try and break the impasse. That pushed the unions into a quicker deal, fearing a loss of influence and negotiating power once the mediators took over.

For Villaraigosa, a former union leader before going into politics, the tentative agreement was seen as a victory. “Mission accomplished. This has been a long eight days, but it’s a great day for everybody now that a deal has been reached,” Villaraigosa said in announcing a deal.

The strike began Nov. 27 as the clerical workers’ union voiced frustration about shipping line employers outsourcing jobs, an accusation the Harbor Employers Assn. has denied.

Though the union is small, it was backed by the 10,000 regional members of the ILWU, which honored the picket line and refused to work. By the end, the strike shut down 10 of the 14 cargo container terminals at the nation’s busiest seaport complex.

The port employers had been pushing for mediation since last week. Clerical workers agreed only after Villaraigosa intervened.

Both union and harbor employers spent most of Tuesday huddled inside a community center near the port.

The mediators joined Villaraigosa there at about 8:30 p.m. as negotiators for the union were voting behind closed doors.