The extension came after the union and an alliance of port operators and shipping lines resolved one of the stickier points in their months-long contract negotiations, involving royalty payments to the longshoremen for each container they unload.
Negotiations will continue until at least midnight Jan. 28. Some important contract issues remain to be resolved, but the head of the Federal Mediation and Conciliation Service, George Cohen, said the agreement on royalties was "a major positive step forward."
"While some significant issues remain in contention, I am cautiously optimistic that they can be resolved in the upcoming 30-day extension period," he said.
The terms of the royalty agreement were not announced.
The master contract between the International Longshoremen's Association and the U.S. Maritime Alliance originally expired in September. The two sides agreed to extend it once before, for 90 days, but it had been set to expire again at 12:01 a.m. Sunday.
As recently as Dec. 19, the president of the longshoremen, Harold Daggett, had said a strike was expected.
A work stoppage would have idled shipments of a vast number of consumer products, from electronics to clothing, and kept U.S. manufacturers from getting parts and raw materials delivered easily.
Business groups expressed relief that the two sides had agreed to keep the ports open.
"A coast-wide port shutdown is not an option. It would have severe economic ramifications for the local, national and even global economies and wreak havoc on the supply chain," said National Retail Federation President Matthew Shay.
Major ports that would have been frozen included the massive terminals serving New York City overseen by the Port Authority of New York and New Jersey, and critical seaports in Savannah, Ga., Houston, and Hampton Roads, Va.
New York Shipping Association President Joseph Curto said avoiding a strike is critical "to thousands of workers who depend on port activities for their livelihood."
Other ports that would have been affected by a strike are in Boston; the Philadelphia area; Baltimore; Wilmington, N.C.; Charleston, S.C.; Jacksonville, Fla.; Port Everglades, Fla.; Miami; Tampa, Fla.; Mobile, Ala.; and New Orleans.
Longshoremen on the West Coast have a separate collective bargaining agreement.