In its last scheduled legislative session of the year, the New York City Council passed major health and environmental regulations on Thursday, establishing a ban on plastic-foam food service containers, extending the city’s ban on public smoking to cover e-cigarettes and requiring composting at large restaurants.

The plastic-foam measure was a final victory of sorts for Mayor Michael R. Bloomberg, though it came with a caveat. In his State of the City address this year, Mr. Bloomberg said the plastic-foam containers were virtually impossible to recycle, and environmentalists have long complained that the foam cups, trays and containers, stained by beverages, grease and food, were needlessly clogging landfills.

Dart Container Corporation, one of the largest makers of such products, and the American Chemistry Council, a trade group, lobbied city officials and council members and spent almost $1 million to convince them otherwise.

The bill that passed unanimously on Thursday was a compromise. Dart has until Jan. 1, 2015, to prove to the sanitation commissioner that “dirty foam” can be collected in the city, recycled and sold in an economically viable way. If Dart fails, the ban will go into effect on July 1, 2015.