Single-use plastic foam containers will be banned in New York City starting in 2019, the mayor's office announced Wednesday.

Starting Jan. 1, restaurants, stores, and manufacturers may not possess or sell polystyrene containers, cups, plates, or trays, or loose fill packaging, known as "packing peanuts."

A judge ruled in favor of the city Friday in its battle with the restaurant industry over the containers.

In its ruling in state court in Manhattan, the court said the single-use food containers cannot be recycled in a way "environmentally effective [or] economically feasible."

Judge Margaret Chan denied an appeal by a restaurant lobbying group and manufacturers. They argued that it was feasible to recycle the containers.

The de Blasio administration has said the ban will protect New York City's environment and its recycling program.

The mayor's office said it will work with businesses to ensure they transition to new, economically-friendly materials.

The city said nonprofits and small business that bring in less than $500,000 in revenue a year can, starting in the fall, apply for exemptions if they can prove that buying alternative polystyrene containers and products would significantly harm their finances.

The Restaurant Action Alliance of New York City said Friday that it was disappointed with the court's decision, because many small business owners depend on the cost-effective foam.

Restaurant group lawyer Randy Mastro told Politico that his clients were reviewing their legal options.

New York City has been trying to ban plastic foam containers since 2013 under former Mayor Michael Bloomberg.