Justice Chan’s ruling, made public on Tuesday, hinged on the question of whether the city had broken its obligation to recycle the used containers, as long as it could do so in a way that was efficient and environmentally effective. The sanitation commissioner, Kathryn Garcia, determined in December that the material was nonrecyclable.

But Dart Container Corporation, a manufacturer in Michigan, put forward a plan that the company’s director of recycling, Michael Westerfield, said on Tuesday would allow the city to start recycling a wider variety of plastics and guarantee that products made from recycled foam containers made their way back into the market. “We view this as a win for recycling and the environment,” he said of Monday’s ruling.

As part of the plan, which Dart said it laid out to city officials in a dozen meetings before the ban was announced in January, the company would buy and install new sorting machines that it said would recover more than 90 percent of the foam. A recycler in Indiana promised to buy the bales of plastic material for at least five years and gave the city a list of buyers who were in the market for products refashioned out of the foam, the ruling said. Under the plan, Dart said only 5 percent to 10 percent of the material would end up in landfills.

Justice Chan said the city had ignored those figures and instead made much more conservative estimates. She said the city could make at least $400,000 by recycling 40 percent of its yearly plastic-foam waste.

Eric A. Goldstein, a lawyer at the Natural Resources Defense Council, said the court had “glossed over” evidence that plastic-foam containers could not be recycled. “There’s not a single major city in the nation that has successfully implemented a recycling program for used polystyrene food containers, and the reason is simple: It doesn’t make economic sense,” Mr. Goldstein said.

Officials from the Bloomberg administration also cast doubt on whether the manufacturer had really found a better way to recycle plastic foam.

“The decision is clearly wrong,” a former deputy mayor for operations, Caswell F. Holloway, who led the administration’s efforts on foam, said in a statement. “The product has inflicted extraordinary environmental harm and should not be in use.” Mr. Holloway added, referring to Mr. de Blasio, “We’re glad he is going to continue this fight.”